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

david 11
  • 75
  • 8

1 Answers1

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

david 11
  • 75
  • 8