HTTP PATCH request in Java
<p>I am trying to make a HTTP PATCH request in Java, but despite my efforts this is not working.
I am trying to PATCH a Json, here is my code:</p>

<pre><code>    HttpResponse response = null;
    BufferedReader rd = null;
    StringBuffer result = new StringBuffer();
    String line = "";

    HttpClient httpclient = HttpClients.createDefault();
    HttpPatch httpPatch = new HttpPatch("http://myURL");

    JsonArrayBuilder Abuilder = Json.createArrayBuilder();
    JsonObjectBuilder oBuilder = Json.createObjectBuilder();
    for(int i=0;i&lt;48;i++){
        Abuilder.add(i+1);
    }
    oBuilder.add("date", "2016-09-08");
    oBuilder.add("values",Abuilder);

    JsonObject jo = Json.createObjectBuilder().add("puissance", Json.createObjectBuilder().add("curves",Json.createArrayBuilder().add(oBuilder))).build();

    try{            
        //Execute and get the response.

        StringEntity params =new StringEntity(jo.toString());

        params.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
        httpPatch.setEntity(params);

        response = httpclient.execute(httpPatch);

        System.out.println("Response Code : " + response.getStatusLine().getStatusCode());
        rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
        while ((line = rd.readLine()) != null) {
                        System.out.println(line);
                        result.append(line);
        }

    }catch(Exception e){

    }
</code></pre>

<p>When I execute this request, I get a</p>

<blockquote>
  <p>"400 Error: The request has an invalid header name".</p>
</blockquote>

<p>When I execute this request using Postman, this is working fine.</p>

<p>I am quite new at HTTP requests so do not hesitate to ask if you need more details.</p>