How to POST JSON data with curl command line?

How to POST JSON data with curl command line?

 

Asked on January 18, 2021 in php.
curl -X POST -H "Content-Type: application/json" \
 -d '{"username":"abc","password":"abc"}' \
 https://api.example.com/v2/login
on January 18, 2021.
Add Comment
1 Answer(s)

    You can also write the username and password in a user.json file. Now use this file to pass the JSON data to curl command line.

    curl -X POST -H "Content-Type: application/json" \
     -d @user.json \
     https://api.example.com/v2/login
    Answered on January 18, 2021.
    Add Comment

    Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.