在发出此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
有什么想法吗?谢谢。
答案 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