title: REST: How to send YAML payload (Java)
body: <p>How does one send a yml payload to a POST entpoint using Java.</p>
  
  <hr>
  
  <h2>Environment</h2>
  
  <p>Request:</p>
  
  <ul>
  <li>language: Java</li>
  <li>lib used: Jersey</li>
  </ul>
  
  <p>Target (<strong>already exists</strong>):</p>
  
  <ul>
  <li>REST endpoint </li>
  <li>type POST </li>
  <li>payload content YAML</li>
  </ul>
  
  <hr>
  
  <h2>Code</h2>
  
  <p>I used to use this to achive the same:</p>
  
  <pre><code>curl --noproxy '*' -X POST --header 'content-type: application/x-yml' --data-binary @file.yaml --url "http://my.yaml.endpoint.com"
  </code></pre>
  
  <p>I tried something like this:</p>
  
  <pre><code>private Client client;
  private ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
  
  YMLPayload yml= null;
      try {
          yml = mapper.readValue(yml, YMLPayload.class);
      } catch (IOException e) {e.printStackTrace();}
  
  Response res = client
                  .target("http://my.yaml.endpoint.com")
                  .request(/* wich mediatype? */)
                  .header("content-type", "application/x-yml")
                  .post(/* how to transform the data? */);
  </code></pre>
  
  <hr>
  
  <p>As Im fairly new to this Topic I might have overlooked something.</p>