We want to send a POST request, and in data we want to send .zip file
We want to read the zip file in Python 2.7 in the same exact way it's been read in Python 3.0, so that the zip file can be send in POST request using 'urllib2.urlopen()' function.
I have tried adding python tags but it seems I am doing something wrong. Sorry for inconvenience. Please help to understand the issue.
Thanks for your help.
post_data = open(zipFilePath, 'rb') readData = post_data.read() headers = { 'Content-Type' : 'application/zip', 'Accept' : '*/*' } url = "someURL" #Python3.0 req = urllib.request.Request(url, post_data.read(), headers) res = urllib.request.urlopen(req) #Python2.7 req = urllib2.Request(url, post_data.read(), headers) res = urllib2.urlopen(req)We have observed that the value of 'readData' for the same zip file is different for Python 3 and Python 2.7
We want to read the zip file in Python 2.7 in the same exact way it's been read in Python 3.0, so that the zip file can be send in POST request using 'urllib2.urlopen()' function.
I have tried adding python tags but it seems I am doing something wrong. Sorry for inconvenience. Please help to understand the issue.
Thanks for your help.