首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用poster向azure ML Web服务发送POST请求

使用poster向azure ML Web服务发送POST请求
EN

Stack Overflow用户
提问于 2015-09-18 07:24:47
回答 1查看 310关注 0票数 0

我已经成功地使用Azure ML部署了一个web服务,并且能够在Azure ML和一个示例R客户端应用程序上获得输出。

不过,我想用火狐的海报得到回应。

我遵循了Azure页面中关于部署web服务的说明,并尝试使用相同的请求头和参数,如下所示

来自azure页面的说明

这是我在Poster上尝试过的

错误消息

我的R代码是有效的

代码语言:javascript
复制
library("RCurl")
library("rjson")

# Accept SSL certificates issued by public Certificate Authorities
options(RCurlOptions = list(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl")))

h = basicTextGatherer()
hdr = basicHeaderGatherer()


req = list(

        Inputs = list(


            "input1" = list(
                "ColumnNames" = list("Smoker", "GenderCD", "Age"),
                "Values" = list( list( "1", "M", "8" ),  list( "1", "M", "8" )  )
            )                ),
        GlobalParameters = setNames(fromJSON('{}'), character(0))
)

body = enc2utf8(toJSON(req))
api_key = "hHlKbffejMGohso5yiJFke0D9yCKwvcXHG8tfIL2d8ccWZz8DN8nqxh9M4h727uVWPz+jmBgm0tKBLxnPO4RyA=="
authz_hdr = paste('Bearer', api_key, sep=' ')

h$reset()
curlPerform(url = "https://ussouthcentral.services.azureml.net/workspaces/79f267a884464b6a95f5819870787918/services/e3490c06c73849f8a78ff320f7e5ffbc/execute?api-version=2.0&details=true",
            httpheader=c('Content-Type' = "application/json", 'Authorization' = authz_hdr),
            postfields=body,
            writefunction = h$update,
            headerfunction = hdr$update,
            verbose = TRUE
            )

headers = hdr$value()
httpStatus = headers["status"]
if (httpStatus >= 400)
{
    print(paste("The request failed with status code:", httpStatus, sep=" "))

    # Print the headers - they include the requert ID and the timestamp, which are useful for debugging the failure
    print(headers)
}

print("Result:")
result = h$value()
print(fromJSON(result))

我的API密钥

代码语言:javascript
复制
hHlKbffejMGohso5yiJFke0D9yCKwvcXHG8tfIL2d8ccWZz8DN8nqxh9M4h727uVWPz+jmBgm0tKBLxnPO4RyA==

我怎样才能形成一个正确有效的URL?

EN

回答 1

Stack Overflow用户

发布于 2015-09-25 08:58:50

"Content to Send“部分不正确,您指定了URL编码,但需要放入application/json。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32641508

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档