我试图从网络服务中提取json数据。我使用HttpPut请求但没有任何反应,我得到了很好的发送价值,我没有错误,我也看不出调试器有什么问题。我也使用了get和delete请求,它们完美地工作...... 我正在将此用于httpPut请求:Http Put Request
这是我的要求:
public class JSONParser {
public static void putJSONfromUrl (String url,String idCat, String valueCat) throws JSONException, IOException {
//--This code works for updating a record from the feed--
HttpPut httpPut = new HttpPut(url);
JSONStringer json = new JSONStringer()
.object()
.key("idcategorie").value(idCat)
.key("nomcategorie").value(valueCat)
.endObject();
StringEntity entity = new StringEntity(json.toString());
entity.setContentType("application/json;charset=UTF-8");//text/plain;charset=UTF-8
entity.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE,"application/json;charset=UTF-8"));
httpPut.setEntity(entity);
// Send request to WCF service
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpResponse response = httpClient.execute(httpPut);
HttpEntity entity1 = response.getEntity();
}
这就是我调用函数的地方
@Override
protected Void doInBackground(String... args) {
JSONParser jParser = new JSONParser();
// Getting JSON from URL
try {
jParser.putJSONfromUrl(urlComplete, valueId,valueDataText);
} catch (IOException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
}