0

How do you translate curl -d "65" to a java httpput entry? I need to do the curl commands here in this link to java using java apache http library.

Acquiring and changing basic data on the Nest thermostat

Here is the curl command:

curl -v -L -X PUT "https://developer-api.nest.com/devices/thermostats/THERMOSTAT_ID/target_temperature_f?auth=AUTH_CODE" -H "Content-Type: application/json" -d "65"

here is my java code :

httpPut.setHeader("Content-Type", "application/json");     
HttpEntity put_entity =  new StringEntity("65"); // Problem is here, I think!
httpPut.setEntity(put_entity);           // or here!
HttpResponse put_response = httpclient.execute(httpPut);
Community
  • 1
  • 1
Moe
  • 185
  • 1
  • 8
  • What error are you getting? It might be that you're not allowing redirects? – Nagesh Susarla Aug 01 '14 at 18:29
  • 1
    If you're building on Android, you may want to side-step this issue and try out the Firebase Android client. It has a learning curve (like any client libs) but the performance is much better than rest + httpPut. https://www.firebase.com/docs/android/quickstart.html – mimming Aug 18 '14 at 19:41
  • There is also some Android sample code using the firebase APIs in the following github link https://github.com/nestlabs/android-NestDK. The firebase logic is separated into a separate library and should be useful for setting/reading the various fields exposed via the Nest API. – Nadewad Sep 09 '14 at 05:18

0 Answers0