2

I've searched a bunch and can't find the answer the answer to this.

I'm trying to pass a binary file as a JSON parameter using multipart/form-data using curl for a POST request. I tried this, but it doesn't work for obvious reasons:

curl -X POST http://api.example.com \
-H "Content-Type:multipart/form-data" \
-F "data={\"key\": \"@text.txt\"};type=application/json"

Any insights would be appreciated.

1 Answer 1

3

Found the answer. It would look like this:

curl -X POST http://api.example.com \ -H "Content-Type:multipart/form-data" \ -F "data={\"key\": \"file1\"};type=application/json" \ -F "[email protected]"

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.