How to write a post request in CURL containing more than one field

552 Views Asked by At
curl -v -XPOST -H'Content-Type: application/json' 'http://api.rofl21.com/login?  
?_request_id=714d3b1001bb01304e6840407e5a5c18&_pretty=true' -d
'{"facebook_access_token":"CAACP8nnDBXEBAHHQUPbZBC5kuLipPhooshJmXwGdk"}                                   

I even want send the gender in the post request as I am sending the fb_access_token.
Where will it be put?
After or before facebook_access_token and how will I write it..syntax??

2

There are 2 best solutions below

0
On BEST ANSWER
curl -v -XPOST -H'Content-Type: application/json' 'http://api.rofl21.com/login?  
?_request_id=714d3b1001bb01304e6840407e5a5c18&_pretty=true' -d
'{"facebook_access_token":"CAACP8nnDBXEBAHHQUPbZBC5kuLipPhooshJmXwGdk", "gender":"something", ... }  

It doesn't matter where you put it.

0
On

The arrangement of the curl parameters are not necessary. You can use anywhere. Also, your URL is broken into multiple lines. Try putting the url into a single line. If that doesn't work then try below one:

curl -v -XPOST -H 'Content-Type: application/json' -d '{"facebook_access_token":"CAACP8nnDBXEBAHHQUPbZBC5kuLipPhooshJmXwGdk"}' 'http://api.rofl21.com/login?_request_id=714d3b1001bb01304e6840407e5a5c18&_pretty=true'

If it doesn't work, then please respond with the output of -v from your screen