title: How do I construct JSON request for form parameter using requests library?
body: <p>I am trying to hit an endpoint with the raw request (CURL) as stated below :</p>
  
  <pre><code>!curl -i -X 'POST' "END_POINT" \
  --form "api_key=xxxxx" \
  --form "image= LOCAL_PATH_TO_IMAGE" 
  </code></pre>
  
  <p>I tried using requests library of Python but I do not know how to construct the JSON request for the above.</p>
  
  <pre><code>def fetch_details(API_KEY, IMAGE_PATH, SERVICE_URL):
  
          form = {
              "api_key": API_KEY , 
              "image":  open(IMAGE_PATH,'rb')
          }
          header = {'content-type': 'application/json'}
          url = SERVICE_URL
          #response = requests.post(url, json = json.dumps(form), headers=header)
          response = requests.post(url, json = json.dumps(json.loads(jsonpickle.encode(form))), headers=header)
          if response.status_code != 200:
            print('There is an error and the error is : ', response.text)
          else:
            attributes = response.json()
            print(attributes)
  </code></pre>
  
  <ol>
  <li>I expect a JSON response for the above request but the output is "There is an error and the error :  Server Error (500)"</li>
  <li>The --form "image" parameter should contain the binary representation of the image.</li>
  </ol>