Skip to main content

All Questions

1 vote
1 answer
2k views

Content-type is different when sending file to FastAPI backend using cURL than Python requests

I have API which accepts JSON data and file (png). This is my fastapi code: @app.post("/api/") async def dummy_file_return(metadata=Body(...),file=File(...)): print("content_type is&...
whitebear's user avatar
  • 12.5k
0 votes
0 answers
1k views

What is the equivalent of HTTP request using "curl ... --data-binary ..." in Python's requests package?

What is the equivalent of HTTP request using "curl ... --data-binary ..." in Python's requests package? The HTTP request's 'Content-Type' is 'multipart/form-data; boundary=...'.
Stephan Haehne's user avatar
0 votes
1 answer
1k views

How to use Python requests to post form as curl PUT -F

I'm trying to replicate the use of curl PUT -F "file=@someFile" using Python's requests. The Content-Type i'm required to use is: multipart/form-data I tried different variations like: r = requests....
Shai Efrati's user avatar
1 vote
1 answer
1k views

Recreate curl command that sends JSON as multipart/form-data using Python-Requests

I'm trying to create a Python-Requests version of the following curl POST command (which works perfectly and provides the expected response): curl -F 'json={"method":"update_video","params":{"video":{...
AdjunctProfessorFalcon's user avatar
3 votes
2 answers
5k views

Convert cURL request to Python-Requests request

I want to convert this cURL request to a Python-Requests request since I am working on a Python wrapper for a REST service MS_WORD_DOCUMENT=... CONTENT_TYPE="application/msword" JSON_REQUEST="{\"...
user avatar
4 votes
2 answers
5k views

Python equivalent to curls --form: Create multipart form-data post request with data in "form" parameter

I'm looking for a python equivalent to this curl command: curl --referer "https://myreferer" --insecure --form "myparam=1234" https://myurl which results in the following request (taken from httpbin....
Michael Helwig's user avatar