title: How to convert a python post request to a Postman POST request
body: <p>I have a python post request to a server where my flask app is hosted. It works fine and I am able to get the desired data.</p>
  <p>But I want to test the API using POSTMAN. I am unable to do that because I am unfamiliar with POSTMAN to some extent.</p>
  <p>Below is the python code that I have.</p>
  <pre><code>import requests
  import ast
  import json
  
  resp1 = {}
  url = 'http://myflaskapiurl:port/route'
  files = {'file': open(r'file that should be uploaded to the server', 'rb')}
  r = requests.post(url, files=files, data={&quot;flag&quot;:2})
  headers = {
      'content-type': &quot;multipart/form-data&quot;,
      'Content-Type': &quot;application/x-www-form-urlencoded&quot;,
      'cache-control': &quot;no-cache&quot;,
  }
  resp1 = ast.literal_eval(r.text)
  print(resp1)
  </code></pre>
  <p>I am struggling with the question whether the data and file that I am trying to post to the server should be in raw json or form-data or x-www-form-urlencoded section of body. Also what should be the actual structure.</p>
  <p>Because every time I POST this data using form-data or x-www-form-urlencoded section of body I get the error saying</p>
  <blockquote>
  <p>werkzeug.exceptions.BadRequestKeyError</p>
  <p>werkzeug.exceptions.HTTPException.wrap..newcls: 400 Bad Request: KeyError: 'file'</p>
  </blockquote>