I'm trying to convert the cURL command to python requests, but hitting a wall. Maybe someone will have an idea.
I was using this site for reference and I have such a cURL command:
curl -F "[email protected]" -H "Authorization: ApiKey xxxxxxxxxxx" -F 'scan_type=Arachni Scan' -F 'tags=test' -F 'active=true' -F 'scan_date=2018-11-15' -F 'engagement=/api/v1/engagements/1/' -F 'eid=1' https://example.com:443/api/v1/importscan/
After the conversion to python, my script extract looks like this:
files = {
'file': ('myfile.json', open('myfile.json', 'rb')),
'scan_type': 'Arachni Scan',
'tags': 'test',
'active': 'true',
'scan_date': '2018-11-15',
'engagement': '/api/v1/engagements/1/',
'eid': '1',
}
response = requests.post('https://example.com:443/api/v1/importscan/', headers=headers, files=files)
print response.text
Unfortunately, the cURL command succeeds, but the python request returns
{"error": "Request is not valid JSON."}
What am I missing here? Thanks!
json.dumps(), (2) using a list instead of a tuple for'file', or (3) doingopen(...).read()instead of justopen()?