Curl POST works in terminal but not with python requests

Viewed 169

I am trying to POST a .wav file to an API using python but i keep getting a missing data file error. I can post the file using curl command in the terminal perfectly fine.

import requests

headers = {
    'Content-Type': 'multipart/form-data',
    'Accept': 'application/json',
}

files = {
    'data_file': ('/TrialData/475503.wav', 
                  open('/TrialData/475503.wav', 'rb')),
    'config': (None, '$(cat config.json)'),
}

response = requests.post('http://example', headers=headers, files=files)

The expected output should be an ID for the job POST

But the output i am getting is "error": "Missing data_file"

0 Answers
Related