0

when I try to curl the following (obviously replaced the username, pw, and dialog id)

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

I get

{"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?"]}

When I try to send another request with the appropriate client ID, conversation ID and new input it returns the same response with an empty input. When I run my xml in watson's dialog tool provided through github I get another answer.

From my understanding the input should show what I sent over. Any ideas why this is not getting processed?

eric MC
  • 766
  • 2
  • 10
  • 36
  • I found this buried deep in some document from IBM curl -u : -H "Accept: application/json" -H "X-WDC-PL-OPT-OUT: 1" -d – eric MC Mar 08 '16 at 21:53
  • 1
    Check my answer here: http://stackoverflow.com/questions/35685955/watson-dialog-curl-conversation-post-request-not-passing-form-data/35686112#35686112 – German Attanasio Mar 09 '16 at 21:26

1 Answers1

0

This is a duplicate of this question. I will write the same answer until we close this.


Original Answer

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=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

Make sure you replace the command with your credentials and dialog-id, conversation-id and client-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.

Community
  • 1
  • 1
German Attanasio
  • 22,217
  • 7
  • 47
  • 63