1

My developers permissions are set to:

  • Away - read/write v2
  • Energy - read v2
  • ETA - read v1
  • Postal code - read v2
  • Structure - read/write v1
  • Thermostat read/write v6

I can get the temperature easily:

$ 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

However I'm consistently getting an "Invalid content sent" response when trying to set the temperature. This is consistent whether I use Curl, Java, python, etc.. I've tried requests in each of the following formats (And more besides, but the below were various examples found in documentation and here on 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"    

Here's the error response in full:

{"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"}
beirtipol
  • 823
  • 5
  • 21
  • What happens when you try setting the Fahrenheit bucket with a Fahrenheit value? – urman Apr 18 '17 at 08:18
  • Same response. I've also tried setting the 'label' to see if it was a number formatting issue. See 'try and set a string field instead' – beirtipol Apr 18 '17 at 14:39
  • You're missing an "s" in thermostats. Should behttps://developer-api.nest.com/devices/thermostats/ADK... etc etc – urman Apr 19 '17 at 16:24
  • JTFC............ Hours I spent fiddling with the damn authentication and formatting. I've added the 's' and am now dealing with a "not found" error. I'll keep at it and post a new one if I'm still stuck in a..... week..... Thank you! – beirtipol Apr 20 '17 at 20:32
  • Got it. Finally working – beirtipol Apr 20 '17 at 20:39

1 Answers1

1

As @urman kindly spotted, I was missing an 's' in "thermostats" in the set request. Words cannot express the embarrassment:)

As a request for any Nest developers reading - could a different error message be returned? Even a 404 would point to something more obviously wrong in the url vs the "content".

beirtipol
  • 823
  • 5
  • 21
  • no problem! It's happened to all of us. You are correct however that the API should have returned a 404 which makes much more sense. – urman Apr 26 '17 at 20:57