I am trying to run a POST call to update dialog node of watson assitant but getting error {"error":"Invalid CSRF Token"}.

my curl command is:

curl -H "Content-Type: application/json" -X POST -u "03abc-6def3-4sds53-9red-394aaaaaaaaaaaae2:passwprd" -d "{\"dialog_node\":\"handler_40_133229823644\",\"type\":\"event_handler\",\"conditions\":\"$version == null\",\"parent\":\"slot_39_1521312319823644\",\"previous_sibling\":\"handler_41_1543623423444\",\"output\":{},\"context\":{\"temp\":\"$version == null\",\"sys_options\":[{\"label\":\"19.5.0\",\"value\":\"1950\"},{\"label\":\"19.2.1\",\"value\":\"1921\"},{\"label\":\"19.2.0\",\"value\":\"1920\"},{\"label\":\"18.11.1\",\"value\":\"1812\"},{\"label\":\"18.11.0\",\"value\":\"1811\"},{\"label\":\"18.8.1\",\"value\":\"1881\"},{\"label\":\"18.8.0\",\"value\":\"1880\"},{\"label\":\"18.5.1\",\"value\":\"1851\"},{\"label\":\"17.5.0\",\"value\":\"1851\"}]},\"actions\":null,\"metadata\":{},\"event_name\":\"input\"}" "https://assistant-us-south.watsonplatform.net/rest/v1/workspaces/adjs42424-73423de-324dd-d397-affasdsade234ad27/dialog_nodes/handler_40_154asdasd823644"

1 Answers

0
chughts On Best Solutions

I think you are missing the version in the url. From the API documentation - https://cloud.ibm.com/apidocs/assistant#update-dialog-node it should be something like -

curl -u "apikey:{apikey}" -H "Content-Type: application/json" -X POST -d "{\"output\":{\"generic\":[{\"response_type\":\"text\",\"values\":[{\"text\":\"Hello! What can I do for you?\"}]}]}}" "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/{workspace_id}/dialog_nodes/greeting?version=2019-02-28"

The example doesn't include the dialog node as part of the -d json structure, and makes use of an IAM Key instead of userid / password authentication. Though if your service credentials still are userid / password based they should still work.