title: POST file in request body to API
body: <p>I'm trying to upload a file in an API that just says:</p>
  
  <blockquote>
    <p>REQUEST
    The request body should contain the contents of the file.
    <a href="https://developer.fortnox.se/documentation/resources/inbox/" rel="nofollow noreferrer">https://developer.fortnox.se/documentation/resources/inbox/</a></p>
  </blockquote>
  
  <p>What I've tried so far:</p>
  
  <pre><code>headers = {
        "Access-Token": settings.FORTNOX_ACCESS_TOKEN,
        "Client-Secret": settings.FORTNOX_CLIENT_SECRET,
        "Content-Type": "multipart/form-data",
        "Accept": "application/json",
  }
  
  file = open(invoice.file.path, 'rb').read()
  r = requests.post("https://api.fortnox.se/3/inbox", data=file, headers=headers)
  </code></pre>
  
  <p>This gives me an error: </p>
  
  <blockquote>
    <p>Ingen fil var uppladdad. (No file was uploaded)</p>
  </blockquote>
  
  <pre><code>headers = {
        "Access-Token": settings.FORTNOX_ACCESS_TOKEN,
        "Client-Secret": settings.FORTNOX_CLIENT_SECRET,
        "Content-Type": "multipart/form-data",
        "Accept": "application/json",
  }
  
  h = httplib2.Http()
  file = open(invoice.file.path, 'rb').read()
  resp, content = h.request('https://api.fortnox.se/3/inbox', "POST", body=file, headers=headers)
  </code></pre>
  
  <p>This gives me the same error: </p>
  
  <blockquote>
    <p>Ingen fil var uppladdad. (No file was uploaded)</p>
  </blockquote>
  
  <p>Are there any other ways to add the file to the request body, or am I doing something wrong here?</p>
  
  <p>Thanks for any help.</p>