title: Making a POST request with Chef
body: <p>I need to post a .json file to a server with a rest API with a Chef recipe, following <a href="https://docs.chef.io/resource_http_request.html" rel="nofollow noreferrer">Chef's documentation</a> I came up with this code:</p>
  
  <pre><code>http_request '/tmp/bpp.json' do
    url 'http://localhost:8080/api/v1/blueprints/bpp'
    headers ({
      'AUTHORIZATION' =&gt; "Basic #{Base64.encode64(user)}",
      'CONTENT-TYPE' =&gt; 'aplication/json'
      })
    action :post
  end
  </code></pre>
  
  <p>For authorization token, <code>user</code> is a variable that contains <code>'user:password'</code></p>
  
  <p>When I run this chef recipe I obtain the following response:</p>
  
  <pre><code>Error executing action `post` on resource 'http_request[POST /tmp/bpp.json]'
  
  Net::HTTPServerException
  ------------------------
  400 "Bad Request"
  </code></pre>
  
  <p>Prior to this I was just executing a <code>curl</code> call and it was working fine, but I need to change to the <code>http_request</code> resource. This was the old (working) <code>curl</code> request:</p>
  
  <pre><code>curl --user user:password -H 'X-Requested-By:My-cookbook' --data @/tmp/bpp.json localhost:8080/api/v1/blueprints/bpp
  </code></pre>
  
  <p>I am not very used with REST apis and seems like an uncharted territory to me.</p>