1
我的开发权限被设置为:无法设置上巢休息API温度
- 客场 - 读/写V2
- 能源 - 读V2
- ETA - 读V1
- 邮政编码 - 阅读V2
- 结构 - 读/写V1
- 温控器的读/写V6
我可以轻松地获得温度:
$ curl -s -L -X GET "https://developer-api.nest.com/devices/thermostats/ADK.....-/target_temperature_c" -H "Content-Type: application/json" -H "Authorization: Bearer c.IQvC....."
$ 11.0
但是我一直让试图设定温度时,响应的“发送内容无效”。这是一致的,无论我使用curl,Java,python等。我已经尝试了以下每种格式的请求(此外,以下是在文档中找到的各种示例和此处的SO)
# With Auth Token in URL
curl -s -L -X PUT "https://developer-api.nest.com/devices/thermostat/ADK.....-/target_temperature_c?auth=c.IQvCNgfU......" -H "Authorization: Bearer c.IQvCNgfU......" -H "Content-Type: application/json" -d "10"
# Without write target in URL
curl -s -L -X PUT "https://developer-api.nest.com/devices/thermostat/ADK.....-" -H "Authorization: Bearer c.IQvCNgfU......" -H "Content-Type: application/json" -d "{\"target_temperature_c\":10}"
# Without write target in URL, not escaping quotes
curl -s -L -X PUT "https://developer-api.nest.com/devices/thermostat/ADK.....-" -H "Authorization: Bearer c.IQvCNgfU......" -H "Content-Type: application/json" -d '{"target_temperature_c":10}'
# With write target in URL
curl -s -L -X PUT "https://developer-api.nest.com/devices/thermostat/ADK.....-/target_temperature_c" -H "Authorization: Bearer c.IQvCNgfU......" -H "Content-Type: application/json" -d "10"
# Try and set a String field instead
curl -s -L -X PUT "https://developer-api.nest.com/devices/thermostat/ADK.....-/label" -H "Authorization: Bearer c.IQvCNgfU......" -H "Content-Type: application/json" -d "A Label"
# Try it without Json as a content type
curl -s -L -X PUT "https://developer-api.nest.com/devices/thermostat/ADK.....-/label" -H "Authorization: Bearer c.IQvCNgfU......" -d "A Label"
这里是完全错误响应:在设置请求“恒温小号”
{"error":"Invalid content sent","type":"https://developer.nest.com/documentation/cloud/error-messages#invalid-content-sent","message":"Invalid content sent","instance":"91c86174-576d-43b7-a586-fcc07a92efa5"}
当您尝试将华氏温度设置为华氏值时会发生什么? – urman
同样的回应。我也尝试设置'标签',看看它是否是一个数字格式问题。请参阅'尝试并设置字符串字段' – beirtipol
您在温控器中缺少“s”。应该是https://developer-api.nest.com/devices/thermostats/ADK ...等等等 – urman