通过curl中的watson中的POST调用更新对话框节点时出错

时间:2019-05-11 04:27:01

标签: ibm-watson

我正在尝试运行POST调用以更新watson助手的对话框节点,但收到错误{“ error”:“无效的CSRF令牌”}。

我的curl命令是:

卷曲-H“内容类型:应用程序/ json” -X POST -u“ 03abc-6def3-4sds53-9red-394aaaaaaaaaaaaaae2: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 个答案:

答案 0 :(得分:0)

我认为您缺少网址中的版本。根据API文档-https://cloud.ibm.com/apidocs/assistant#update-dialog-node,它应该类似于-

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"

该示例未将对话框节点包含在-d json结构中,而是使用了IAM密钥而不是用户ID /密码身份验证。但是,如果您的服务凭据仍基于用户ID /密码,它们仍然可以正常工作。