2017-04-16 38 views
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"} 
+0

當您嘗試將華氏溫度設置爲華氏值時會發生什麼? – urman

+0

同樣的迴應。我也嘗試設置'標籤',看看它是否是一個數字格式問題。請參閱'嘗試並設置字符串字段' – beirtipol

+0

您在溫控器中缺少「s」。應該是https://developer-api.nest.com/devices/thermostats/ADK ...等等等 – urman

回答

1

由於@urman親切斑點,我缺少一個「s」。單詞無法表達尷尬:)

作爲任何Nest開發人員閱讀的請求 - 是否可以返回不同的錯誤消息?甚至404會指向URL與「內容」中更明顯的錯誤。

+0

沒問題!這發生在我們所有人身上。然而,你是正確的,API應該已經返回了一個更有意義的404。 – urman