title: Http Put Json Android
body: <p>i try to develop an server/client app. Server is glassfish, client android(Google http api).</p>
  
  <p>I use rest to transport data.</p>
  
  <p>If i do a Get all is nice.</p>
  
  <p>Now i want to do a Put, but i dont get my content on my server...</p>
  
  <p>Client :</p>
  
  <pre><code>JSONObject jO = new JSONObject(json);
  final HttpContent content = new JsonHttpContent(new JacksonFactory(), jO);
  HttpRequest request = requestFactory.buildPutRequest(url, content);
  </code></pre>
  
  <p>Server:</p>
  
  <pre><code>@PUT
  @Consumes(MediaType.APPLICATION_JSON)
  public JsonObject putJson(JsonObject jO, @Context HttpHeaders headers){
  </code></pre>
  
  <p>With a rest debugger (Postman), I can send some JSON to the server and get it.
  Do the put with android the <code>JsonObject</code> is empty (the content debug on android is fill).</p>
  
  <p>Can you help me?</p>
  
  <p>Update with volley</p>
  
  <p>Server:</p>
  
  <pre><code>    /**
   * PUT method for updating or creating an instance of Registration
   *
   * @param param1
   * @param jO
   * @param headers
   * @return 
   */
  @POST
  @Consumes("application/json")
  public JsonObject putJson(@QueryParam("email") String param1, @Context HttpHeaders headers){
  
      Player tmpPlayer; 
      System.out.println(param1); 
   JsonObject value = Json.createObjectBuilder()
   .add("firstName", "John")
   .add("lastName", "Smith").build();
  
      return value;
  </code></pre>
  
  <p>client:</p>
  
  <pre><code>JsonObjectRequest request = new JsonObjectRequest(Request.Method.POST,
              URL_REGISTER, null,
              new Response.Listener&lt;JSONObject&gt;() {
  
                  @Override
                  public void onResponse(JSONObject response) {
                      System.out.println(response.toString());
                  }
              }, new Response.ErrorListener() {
  
          @Override
          public void onErrorResponse(VolleyError error) {
              System.out.println("Error");
          }
      }) {
  
          @Override
          public String getBodyContentType() {
              return "application/json";
          }
  
          @Override
          public Map&lt;String, String&gt; getHeaders() throws AuthFailureError {
              HashMap&lt;String, String&gt; headers = new HashMap&lt;String, String&gt;();
              headers.put("Content-Type", "application/json");
              return headers;
          }
  
          @Override
          protected Map&lt;String, String&gt; getParams() {
              Map&lt;String, String&gt; params = new HashMap&lt;String, String&gt;();
  
              JSONObject tmpObject = new JSONObject();
              try {
                  tmpObject.put("name", "simon");
              } catch (JSONException e) {
                  e.printStackTrace();
              }
              params.put("name", tmpObject.toString());
              params.put("email", "test@test");
              params.put("password", "1234");
  
              return params;
          }
  
      };
  
      RequestQueue requestQueue = Volley.newRequestQueue(registration);
      requestQueue.add(request);
      requestQueue.start();
  </code></pre>
  
  <p>Thanks Simon</p>