user1584421
user1584421

Reputation: 3843

Converting a curl POST request, to a curl JSON POST request

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?

Upvotes: 1

Views: 93

Answers (1)

Prasad  14723312
Prasad 14723312

Reputation: 564

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

Upvotes: 1

Related Questions