0

i'm trying to put json data from a webservice. I'm using HttpPut request but nothing happen, i get the good value to send, i'have no error and i can't see anything wrong with the debugguer. I'm using get and delete request too and they work perfectly... I'was using this for httpPut request : Http Put Request

Here is my 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();
    }

And here is where i call the function

    @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;
    }
}
Community
  • 1
  • 1

0 Answers0