AzureCognitive R 包翻译服务 returns http 400: "body of request is not valid JSON."
AzureCognitive R package translate service returns http 400: "body of request is not valid JSON."
我尝试使用 AzureCognitive R 包使翻译服务正常工作,但出现 HTTP 400 错误,我似乎无法修复它。
# Initial setup
# I've already did the create login
# az <- AzureRMR::create_azure_login(tenant = "<tenant>")
az <- AzureRMR::get_azure_login()
sub <- az$get_subscription(id = "<id>")
rg <- sub$get_resource_group("<resource-group>")
# retrieve it
cogsvc <- rg$get_cognitive_service(name = "<name>")
# getting the endpoint from the resource object
endp <- cogsvc$get_endpoint()
############################
# This is where it fails
############################
call_cognitive_endpoint(endpoint = endp,
operation = "translate",
options = list('api-version' = "3.0",
'from' = 'en',
'to' = 'dk'),
body = "[{'Text':'Hello, what is your name?'}]",
http_verb = "POST")
call_cognitive_endpoint(endpoint = endp,
operation = "translate",
options = list('api-version' = "3.0",
'from' = 'en',
'to' = 'dk'),
body = list(text = "Hello, what is your name"),
http_verb = "POST")
有人可以看看这是错误还是我做错了什么?
按照此 example,您可以将正文传递为 body=list(list(text = "Hello, what is your name"")),
call_cognitive_endpoint(endpoint = endp,
operation = "translate",
options = list('api-version' = "3.0",
'from' = 'en',
'to' = 'dk'),
body = list(list(text = "Hello, what is your name")),
http_verb = "POST")
我尝试使用 AzureCognitive R 包使翻译服务正常工作,但出现 HTTP 400 错误,我似乎无法修复它。
# Initial setup
# I've already did the create login
# az <- AzureRMR::create_azure_login(tenant = "<tenant>")
az <- AzureRMR::get_azure_login()
sub <- az$get_subscription(id = "<id>")
rg <- sub$get_resource_group("<resource-group>")
# retrieve it
cogsvc <- rg$get_cognitive_service(name = "<name>")
# getting the endpoint from the resource object
endp <- cogsvc$get_endpoint()
############################
# This is where it fails
############################
call_cognitive_endpoint(endpoint = endp,
operation = "translate",
options = list('api-version' = "3.0",
'from' = 'en',
'to' = 'dk'),
body = "[{'Text':'Hello, what is your name?'}]",
http_verb = "POST")
call_cognitive_endpoint(endpoint = endp,
operation = "translate",
options = list('api-version' = "3.0",
'from' = 'en',
'to' = 'dk'),
body = list(text = "Hello, what is your name"),
http_verb = "POST")
有人可以看看这是错误还是我做错了什么?
按照此 example,您可以将正文传递为 body=list(list(text = "Hello, what is your name"")),
call_cognitive_endpoint(endpoint = endp,
operation = "translate",
options = list('api-version' = "3.0",
'from' = 'en',
'to' = 'dk'),
body = list(list(text = "Hello, what is your name")),
http_verb = "POST")