Watson Curl 不持久/返回输入

Watson Curl Not Persisting / returning input

当我尝试卷曲以下内容时(显然替换了用户名、密码和对话框 ID)

curl -u "username":"password" -X POST --form input="hi watson" "https://gateway.watsonplatform.net/dialog/api/v1/dialogs/dialog-id/conversation"

我明白了

{"conversation_id":xxxxxx,"client_id":xxxxxx,"input": "","confidence":-1.0,"response":["Hi, I'm Watson! I can help you order a pizza, what size would you like?"]}

当我尝试使用适当的客户端 ID、对话 ID 和新输入发送另一个请求时,它 returns 相同的响应但输入为空。当我 运行 我的 xml 在通过 github 提供的 watson 对话工具中时,我得到了另一个答案。

根据我的理解,输入应该显示我发送过来的内容。为什么这没有得到处理有什么想法吗?

这是 的副本。我会写同样的答案,直到我们关闭它。


原答案

服务需要一个 application/x-www-form-urlencoded POST 请求

要在 curl 中执行此操作,您需要使用 -d 参数:

curl -u "USERNAME":"PASSWORD" -X POST 
  -d conversation_id=conversation-id 
  -d client_id=client-id
  -d input="What type of toppings do you have?"
  "https://gateway.watsonplatform.net/dialog/api/v1/dialogs/dialog-id/conversation"
-d, --data

确保将命令替换为您的凭据和 dialog-idconversation-idclient-id

(HTTP) Sends the specified data in a POST request to the HTTP server, in the same way that a browser does when a user has filled in an HTML form and presses the submit button. This will cause curl to pass the data to the server using the content-type application/x-www-form-urlencoded. Compare to -F, --form.