0

when i make the following request:

curl -X POST http://localhost:8080/endpoint \
  -F "file=filepath/example.zip" \
  -H "Content-Type: multipart/form-data"

everything works fine. However, when i try to do the same in python:

import requests

url = "http://localhost:8080/endpoint"

files = {"file": open("example.zip", "rb")}
headers = {"Content-Type": "multipart/form-data"}

r = requests.post(url, files=files, headers=headers)

the api gives me an error. are these two code snippets not equivalent? thanks

1 Answer 1

1

the issue was this:

multipart data POST using python requests: no multipart boundary was found

it seems as though setting

headers = {"Content-Type": "multipart/form-data"}

caused the issue. i removed it and it works

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.