Search code examples
nest-api

How to set data using Nest REST API?


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.


Solution

  • 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