cURL error - cannot send text value for -d

半城伤御伤魂 提交于 2019-12-13 19:30:02

问题


Executing:

curl.exe -k -L -X PUT "https://developer-api.nest.com/devices/thermostats/[DEVICE_ID]/hvac_mode.json?auth=[ACCESS_TOKEN]" -H "Content-Type: application/json" -d "heat"

Produces the error:

{"error":"Invalid content sent"}

Using the exact same command but replacing hvac_mode with target_temperature_f and "heat" with 65 (any number will work and yes without quotes) works and the data changes upstream. I've tried sending "heat" without quotes and with '' instead of "" - no difference.

Permissions are good. Documentation says I should be able to do this. I am currently in "off" hvac_mode.

If I replace "heat" with '{"target_temperature_f": 73}', I get:

{"error":"Invalid content sent"}curl: (3) [globbing] unmatched close brace/bracket in column 3

回答1:


The following works in Linux:

curl.exe -k -L -X PUT "https://developer-api.nest.com/devices/thermostats/[DEVICE_ID]?auth=[ACCESS_TOKEN]" -H "Content-Type: application/json" -d '{"hvac_mode":"heat"}'

and in Windows:

curl.exe -k -L -X PUT "https://developer-api.nest.com/devices/thermostats/[DEVICE_ID]?auth=[ACCESS_TOKEN]" -H "Content-Type: application/json" -d "{\"hvac_mode\":\"heat\"}"


来源:https://stackoverflow.com/questions/26638731/curl-error-cannot-send-text-value-for-d

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!