Watson对话框cURL对话后请求不传递表单数据 [英] Watson dialog cURL conversation post request not passing form data
问题描述
在进行后期cURL请求时,如下所示,尝试继续创建的会话watson,而不返回新会话。
curl -uUSERNAME:PASSWORD-X POST --form conversation_id = CONVOID --form client_id = CLIENTID --form input =你有什么类型的浇头? https://gateway.watsonplatform.net/dialog/api/v1/dialogs/DIALOGID/conversation
如果我使用下面的cURL它工作正常。
curl -uUSERNAME:PASSWORD--dataconversation_id = CONVOID& client_id = CLIENTID& input =的浇头你有吗? https://gateway.watsonplatform.net/dialog/api/v1/dialogs/DIALOGID/conversation
我的问题是,现在当试图编写ac#wrapper我运行在同一问题POST请求无法正确传输其表单数据。
发生了什么?
我需要一个c#MVC等同于 - data
格式化。 (目前使用 HttpClient.PostAsync
),或者弄清楚使用发布请求继续会话的确是错误的。
至于我可以告诉我在c#正确复制post请求,所以我不认为有两个问题。 (只有一个post请求问题,不是cURL问题,然后C#实现问题。)
对于什么是值得我留下的格式我提交他们的命令,只有用BLOCKCAPITALS替换敏感值。如果它看起来像我错过了一个引号或大括号,这是因为我有和可能是问题的原因。
服务需要一个应用程序/ x-www-form-urlencoded
POST请求
要在 curl
中执行,您需要使用 -d
参数:
curl -uUSERNAME:PASSWORD-X POST
- d conversation_id = CONVOID
-d client_id = CLIENTID
-d input =你有什么类型的浇头?
https://gateway.watsonplatform.net/dialog/api/v1/dialogs/DIALOGID/conversation
POST请求到HTTP服务器,与浏览器在用户填写HTML表单并按提交按钮时的方式相同。这将导致curl使用内容类型应用程序/ x-www-form-urlencoded将数据传递到服务器。与-F,--form比较。
Curl 文档
When making a post cURL request as below to try and continue a created conversation watson instead returns a new conversation.
curl -u "USERNAME":"PASSWORD" -X POST --form conversation_id=CONVOID --form client_id=CLIENTID --form input="What type of toppings do you have?" "https://gateway.watsonplatform.net/dialog/api/v1/dialogs/DIALOGID/conversation"
If i use the below cURL it works fine.
curl -u "USERNAME":"PASSWORD" --data "conversation_id=CONVOID&client_id=CLIENTID&input=What type of toppings do you have?" https://gateway.watsonplatform.net/dialog/api/v1/dialogs/DIALOGID/conversation
My issue being that now when trying to write a c# wrapper i'm running in to the same issue that POST requests fail to transmit their form data correctly.
What's going on ?
I either need a c# MVC equivalent to the "--data
" formatting. ( currently using HttpClient.PostAsync
) or to figure out what is exactly wrong with using post requests to continue conversations.
As far as i can tell i am replicating the post request in c# correctly so i don't think there are two issues. ( just one post request issue, not a cURL issue then a C# implementation issue.)
For what it's worth i have left the commands in the format i submitted them, only replacing sensitive values with BLOCKCAPITALS. If it looks like i've missed a quotation mark or curly bracket , it's because i have and may be the cause of the issue.
The service expects an application/x-www-form-urlencoded
POST request
To do that in curl
you need to use the -d
parameter:
curl -u "USERNAME":"PASSWORD" -X POST
-d conversation_id=CONVOID
-d client_id=CLIENTID
-d input="What type of toppings do you have?"
"https://gateway.watsonplatform.net/dialog/api/v1/dialogs/DIALOGID/conversation"
-d, --data
(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.
Curl documentation
这篇关于Watson对话框cURL对话后请求不传递表单数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!