Matching File Input Request Example

I am trying to build a matching request using csv file using python request library. I am getting <Response [500]> What I am doing wrong here?


My example csv input file contains just one column with the header name and 1 row, like this:

name

Facebook


There is my code:


request_url = "https://api-eit.refinitiv.com/permid/match/file&quot;

headers = { 'Content-Type': 'multipart/form-data',

'x-ag-access-token': my_apikey,

'x-openmatch-numberOfMatchesPerRecord': '1',

'x-openmatch-dataType': 'Organization'}


files = {'file': open('C:/My_Folder/input_file.csv') }

response = requests.post(url=request_url, headers=headers, files=files)

r = response.json()

print(r)

----------

<Response [500]>

{'error': {'status': {'code': '500',

'errorCode': 'Server Error',

'errorDescription': 'java.lang.NullPointerException'}}}

Welcome!

It looks like you're new here. Sign in or register to get started.

Best Answer

  • zoya faberov
    zoya faberov ✭✭✭✭✭
    Answer ✓

    Hello @EA_MZ ,

    In Python, by specifying "files" as parameter, the request is already 'Content-Type': 'multipart/form-data':

    This discussion thread may be helpful.

    It seems, that if you have it twice, Requests module gets it slightly off, resulting in the invalid submission.

    It is mandatory.

Answers

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.