denimgroup / threadfix

ThreadFix is a software vulnerability management platform. This GitHub site is far out of date. Please go to www.threadfix.it for up-to-date information.
339 stars 127 forks source link

Error: "Current request is not a multipart request" in /rest/applications/{appId}/upload #1779

Closed nikhilgeo closed 7 years ago

nikhilgeo commented 7 years ago

I'm invoking the upload api from the python like below:

    headers = {'Accept': 'application/json', 'content-Type':'multipart/form-data'}
    payload = {'file': report}
    url = "http://10.112.184.177:8080/threadfix/rest/applications/"+app_id+"/upload?apiKey=XXXXX"
    r = requests.post(url, headers=headers, data=payload)

This gives me error {'message': 'Current request is not a multipart request', u'object': None, u'responseCode': -1, u'success': False}.

Any idea how to resolve this ..?

nikhilgeo commented 7 years ago

I changed my code to the below:

headers = {'Accept': 'application/json', 'content-Type':'multipart/form-data'}
files = {'file': open(report, 'rb')}
url = "http://X.X.X.X:8080/threadfix/rest/applications/"+app_id+"/upload?apiKey=XXX"
r = requests.post(url, headers=headers, files=files)
data = json.loads(r.text)
print data

It now shows another error: {'message': 'Failed to parse multipart servlet request; nested exception is org.apache.commons.fileupload.FileUploadException: the request was rejected because no multipart boundary was found', 'object': None, 'responseCode': -1, 'success': False}

Any help is much appreciated.

nikhilgeo commented 7 years ago

I figured it out.

I removed 'content-Type':'multipart/form-data' from the headers. thanks anyways !!