Dialogflow v2 REST调用返回400错误请求

时间:2018-09-10 22:15:19

标签: dialogflow

在发出此entityTypes.create调用时,我收到一个400错误的请求:

wget --header="Authorization: Bearer ${TOKEN}" \
 --post-data=' { "displayName": "writer1", "kind": "KIND_MAP", "autoExpansionMode": "AUTO_EXPANSION_MODE_DEFAULT", "entities": [ { "value": "Virginia Woolf", "synonyms": [ "Virginia Woolf" ] } }' \
 https://dialogflow.googleapis.com/v2/projects/MyProject/agent/entityTypes

但是,这-entityTypes.list-工作正常:

wget --header="Authorization: Bearer ${TOKEN}" \
https://dialogflow.googleapis.com/v2/projects/MyProject/agent/entityTypes

有什么想法吗?谢谢。

1 个答案:

答案 0 :(得分:2)

默认情况下,--post-data使用内容类型为application/x-www-form-urlencoded。该API要求内容类型为application/json

我倾向于使用更类似的东西

wget \
 --header="Authorization: Bearer ${TOKEN}" \
 --header="Content-type: application/json" \
 --post-data='{ ... }' \
 https://dialogflow.googleapis.com/v2/projects/MyProject/agent/entityTypes