IBM Cloud 查询结构 ruby
IBM Cloud Query Structure ruby
我在理解如何构建对 IBM Tone Analyzer 服务的请求时遇到问题。他们没有 ruby 的 SDK,所以我只是想创建一个 http 请求。
但是,我不断收到 'no credentials supplied' 回复。我只是不知道这些凭证必须放在哪里。
我试过:
body: {username:'...', password:'...'}
我的凭据有效,我能够通过 curl 命令获得响应。
我尝试将这些直接放入查询中。我只是迷路了。
编辑:我正在使用 HTTParty 发出我的请求。目前我把我的资历放在我能想到的每个领域,所以它看起来像
response = HTTParty.post(
URL,
header: @header,
data: {
text: @body,
username: @user,
password: @password
},
body: {
text: @body,
username: @user,
password: @password
},
credentials: {
text: @body,
username: @user,
password: @password
},
user: {
username: @user,
password: @password
},
options: {
username: @user,
password: @password
},
query: {
text: @body,
username: @user,
password: @password
})
来自 the documentation it appears these credentials are not supplied via the API body, but instead via HTTP Auth。这意味着您可以这样称呼它:
response = HTTParty.post(
URL,
header: @header,
data: {
text: @body,
},
basic_auth: {
username: @user,
password: @password
}
)
我在理解如何构建对 IBM Tone Analyzer 服务的请求时遇到问题。他们没有 ruby 的 SDK,所以我只是想创建一个 http 请求。
但是,我不断收到 'no credentials supplied' 回复。我只是不知道这些凭证必须放在哪里。
我试过:
body: {username:'...', password:'...'}
我的凭据有效,我能够通过 curl 命令获得响应。
我尝试将这些直接放入查询中。我只是迷路了。
编辑:我正在使用 HTTParty 发出我的请求。目前我把我的资历放在我能想到的每个领域,所以它看起来像
response = HTTParty.post(
URL,
header: @header,
data: {
text: @body,
username: @user,
password: @password
},
body: {
text: @body,
username: @user,
password: @password
},
credentials: {
text: @body,
username: @user,
password: @password
},
user: {
username: @user,
password: @password
},
options: {
username: @user,
password: @password
},
query: {
text: @body,
username: @user,
password: @password
})
来自 the documentation it appears these credentials are not supplied via the API body, but instead via HTTP Auth。这意味着您可以这样称呼它:
response = HTTParty.post(
URL,
header: @header,
data: {
text: @body,
},
basic_auth: {
username: @user,
password: @password
}
)