Android Http在REST中类似于curl -d

时间:2014-07-30 22:10:07

标签: java android curl nest-api

你如何翻译curl -d" 65"到java httpput条目?我需要在这个使用java apache http库的java链接中执行curl命令。

Acquiring and changing basic data on the Nest thermostat

这是curl命令:

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"

这是我的java代码:

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);

0 个答案:

没有答案