title: JMeter API set content-type
body: <p>I'm introducing in JMeter Pure java, how to set <code>content-type application/json</code> in httpSampler?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>// HTTP Sampler
          HTTPSampler httpSampler = new HTTPSampler();
          httpSampler.setDomain("localhost");
          httpSampler.setPort(8080);
    httpSampler.setPath("/posts");
          httpSampler.setMethod("POST");
          httpSampler.setName("API");
  
    String data = "{\"items\":[{\"stacking_limit\":null,\"id\":\"MLA60428354\",\"weight\":300,\"height\":20,\"only_rotate_axis\":null,\"width\":35,\"length\":45,\"quantity\":1}],\"pack\":{\"weight\":2000,\"height\":100,\"width\":100,\"length\":100}}";
    httpSampler.addNonEncodedArgument("", data, "");
    httpSampler.setPostBodyRaw(true);
  
    HeaderManager headerManager = new HeaderManager();
    Header h = new Header("Content-Type", "application/json");
    headerManager.add(h);
    httpSampler.setHeaderManager(headerManager);</code></pre>
  </div>
  </div>
  </p>
  
  <p>When I send a post to the server, I check that headers contain <code>application/x-www-form-urlencoded</code>, how to change it?</p>