title: How to upload PDF file using request POST method and requests must be formatted as multipart MIME using python for xeroAPI?
body: <p>I'm trying to upload PDF-file in the Xero account using the python request library (POST method) and Xeros FilesAPI said &quot;Requests must be formatted as multipart MIME&quot; and have some required fields (<a href="https://developer.xero.com/documentation/files-api/files#POST" rel="nofollow noreferrer">link</a>) but I don't how to do that exactly...If I do GET-request I'm getting the list of files in the Xero account but having a problem while posting the file (POST-request)...</p>
  <p>My Code:</p>
  <pre><code>post_url = 'https://api.xero.com/files.xro/1.0/Files/'
  files = {'file': open('/home/mobin/PycharmProjects/s3toxero/data/in_test_upload.pdf', 'rb')}
  
  response = requests.post(
      post_url,
      headers={
          'Authorization': 'Bearer ' + new_tokens[0],
          'Xero-tenant-id': xero_tenant_id,
          'Accept': 'application/json',
          'Content-type': 'multipart/form-data; boundary=JLQPFBPUP0',
          'Content-Length': '1068',
      },
      files=files,
  )
  
  json_response = response.json()
  
  print(f'Uploading Responsoe ==&gt; {json_response}')
  print(f'Uploading Responsoe ==&gt; {response}')
  </code></pre>
  <p>Error Mesage/Response:</p>
  <pre><code>Uploading Responsoe ==&gt; [{'type': 'Validation', 'title': 'Validation failure', 'detail': 'No file is was attached'}]
  Uploading Responsoe ==&gt; &lt;Response [400]&gt;
  </code></pre>