I'm trying to upload an exported scan (.nessus) file to a Nessus Community Edition server using python and the Nessus REST API (func POST /file/upload) however I keep getting the response null
like this {"fileuploaded":null}
in the response.
I can't seem to see in the API doc's what else could be required.
def upload_scan_file(_path):
_url = url+"/file/upload"
_head['Content-type'] = ''
_files = {"file": open(_path, 'rb'), "no_enc" : "0"}
r = requests.post(_url, headers=_head, verify=False, files=_files)
return r.text
The reason I unset the Content-type
key in the headers dict is that I get a {'error': Content-type: application/json not supported'}
_path
contains the file path.
_head
is a dict of header values that I use to query all the others information.
Any help would be appreciated.
Since you are uploading file through files=_files
, so you should not specify Content-type
. Content-type
ought to be set by requests library. Read: Whats Content-Type value within a HTTP-Request when uploading content? . Try to remove _head['Content-type'] = ''
and change _files
to _files = {"file": open(_path, 'rb')}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.