在这种情况下,您是否使用 curl 调用 API?根据你的例子...
通过提供您要使用的服务实例的服务凭证username
中提供的和password
来调用 Personality Insights 。API 使用基本身份验证。HTTP
对于身份验证:
curl -u "{username}":"{password}"
"https://gateway.watsonplatform.net/personality-insights/api/v3/{method}"
Bluemix 从所有请求中收集数据并使用这些数据来改进 Watson 服务。
请求记录:
curl -u "{username}":"{password}"
--header "X-Watson-Learning-Opt-Out: true"
"https://gateway.watsonplatform.net/personality-insights/api/v3/{method}"
调用和获取响应的方法:
curl -X POST -u "{username}:{password}"
--header "Content-Type: application/json"
--data-binary @profile.json
"https://gateway.watsonplatform.net/personality-insights/api/v3/profile?version=2016-10-20&consumption_preferences=true&raw_scores=true"
IBM Watson API 使用标准 HTTP 响应代码来指示方法是否成功完成。
200 级响应始终表示成功。
400 级响应表示某种故障。
500 级响应通常表示内部系统错误。
查看 IBM 的此文档以进行开发,其中包含所有示例如何调用以及是否有错误原因。这用于验证如何工作以及如何使用。
Demo here,如果你愿意,你可以从 github 上 fork。