1

I have tried to set the target temperature the following script and it returns {"error":"Invalid content sent"}. How can I set the target temperature using the REST API?

#!/bin/bash

DATA='{"devices":{"thermostats":{"DEVICE_ID":{"target_temperature_f":75}}}'

curl --cacert curl-ca-bundle.crt -L -X PUT --data $DATA "https://developer-api.nest.com/?auth=ACCESS_CODE"

Note that I redacted the actual device id and access code.

Stephen305
  • 1,077
  • 3
  • 22
  • 30
  • Have you tried setting the `Content-Type` header to tell the API service that it's JSON data that's being sent? `-H 'Content-Type: application/json'` – Jason Z Mar 12 '15 at 21:34
  • I just tried it. I updated the command in the question to reflect the latest command I have tried. I am still getting an error. – Stephen305 Mar 12 '15 at 21:44
  • I got it to work using your suggestion. See answer below. – Stephen305 Mar 12 '15 at 22:02

1 Answers1

0

The following works:

#!/bin/bash

DATA='{"target_temperature_f":76}'

curl --cacert curl-ca-bundle.crt -v -L -X PUT "https://developer-api.nest.com/devices/thermostats/DEVICE_ID?auth=ACCESS_CODE" -H "Content-Type: application/json" -d DATA
Stephen305
  • 1,077
  • 3
  • 22
  • 30