1

I am using this curl line, in order to trigger a POST request to my server:

curl --data "item=my_item&is_done=true" 127.0.0.1:5000/convert

How can i convert the curl line, in order to send the same parameters, but through JSON?

1 Answer 1

1

You can use below command

curl -d ‘{“item”: “my_item”, “is_done”: ”true”}’ -H “Content-Type: application/json” -x POST 127.0.0.1:5000/convert

Or

If you want to share parameters in file abcd.json then ,

curl -d “@abcd.json” -H “Content-Type: application/json” -x POST 127.0.0.1:5000/convert

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

2 Comments

I actually used this: curl --header "Content-Type: application/json" --request POST --data '{"item":"ZycugK6yXdHgf8foQTUnKY.txt","method":"my_method"}' 0.0.0.0:5000/convert
Why the IP address is 0.0.0.0 instead of 127.0.0.1 ?

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.