curl: (6) 无法解析主机:—-header

curl: (6) Could not resolve host: —-header

这是我的命令,我正在使用 Mac os,

curl -X POST \
-u "{username}":"{password}" —-header "Content-Type:application/json" --data "{\"input\": {\"text\": \"Turn on the lights\"}, \"context\": {\"conversation_id\": \"1b7b67c0-90ed-45dc-8508-9488bc483d5b\", \"system\": {"dialog_stack":[{"dialog_node":"root"}], \"dialog_turn_counter\": 1, \"dialog_request_counter\": 1}}}" "https://gateway.watsonplatform.net/conversation/api/v1/workspaces/25dfa8a0-0263-471b-8980-317e68c30488/message?version=2016-09-20"

当我应用这个时,错误日志是,

curl: (6) Could not resolve host: —-header
curl: (6) Could not resolve host: Content-Type
{"error":"Unsupported Media Type"}

请帮我解决这个问题。

提前致谢...

在您的 —-header 选项中,第一个字符不是普通的连字符 (U+002d)。相反,它是一个破折号 (U+2014)。将其更改为普通的连字符,一切都会按预期工作。

您可以使用此代码解决这些问题

curl -X POST -u "CONVERSATION_USERNAME":"CONVERSATION_PASSWORD" -H "Content-Type:application/json" -d "{\"input\": {\"text\":\" \"}}" "https://gateway.watsonplatform.net/conversation/api/v1/workspaces/CONVERSATION_ID/message?version=2016-07-11"