cURL错误 - 无法发送-d的文本值 [英] cURL error - cannot send text value for -d

查看:2718
本文介绍了cURL错误 - 无法发送-d的文本值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

执行:

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"

产生错误:

{"error":"Invalid content sent"}

使用完全相同的命令,但替换 hvac_mode target_temperature_f heat 65 (任何数字将工作,是不使用引号)工作和上游的数据更改。我已经尝试发送没有引号和而不是的heat - 没有区别。

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.

权限是好的。 文档说我应该能够这样做。我目前在off hvac_mode

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

如果我用'{target_temperature_f:73}'替换heat,我得到:

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


推荐答案

以下适用于Linux:

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"}'


b $ b

和Windows:

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\"}"

这篇关于cURL错误 - 无法发送-d的文本值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆