【发布时间】:2021-12-24 00:21:11
【问题描述】:
我尝试使用 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被传递为
body=list(list(Text="Hello world")), -
优秀@DeepDave-MT。你想回答吗?这有效:
call_cognitive_endpoint(endpoint = endp, operation = "translate", options = list('api-version' = "3.0", 'from' = 'en', 'to' = 'da'),body = list(list(text = 'Hello, what is your name')), http_verb = "POST")
标签: r azure azure-cognitive-services