I have a request that i need to migrate via python.requests. It looks like this:
------WebKitFormBoundarSomeBoundary
Content-Disposition: form-data; name="input"; filename="blob"
Content-Type: application/json
{
some JSON
}
------WebKitFormBoundarySomeBoundary
Content-Disposition: form-data; name="file"; filename="contractFile.pdf"
Content-Type: application/pdf
------WebKitFormBoundarySomeBoundary--
I'm trying to import it via python.requests but always have problems with API
I tried some things, for example:
url = {url}:{host}/{end_point}
multipart_data = MultipartEncoder(
fields={
'input': 'name',
'file': ('contractFile.pdf', open('contractFile.pdf', 'rb'), 'application/pdf')
}
)
r = requests.post(url, data=multipart_data, auth=('admin', 'admin'), headers={
'Content-Type': multipart_data.content_type})
getting an error - "Content type application/octet-stream not supported"
url = {url}:{host}/{end_point}
files = {'file': (
'contractFile.pdf',
open('contractFile.pdf', 'rb'),
'application/pdf'
)}
payload = {'input': {'"name": "template20"'}}
json.dumps(list(payload))
r = requests.post(url, data=payload, auth=('admin', 'admin'), files=files)
print(r.text, '\n\n', r.headers['content-type'], '\n', r.headers['accept'])
Same error here - "Content type application/octet-stream not supported"
I don't understand why my content-type is octet-stream, I check headers and it's not even in it