问题
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