How to do HTTP-request/call with JSON payload from command-line?

Roalt picture Roalt · Nov 30, 2010 · Viewed 92.2k times · Source

What's the easiest way to do a JSON call from the command-line? I have a website that does a JSON call to retrieve additional data.

The Request Payload as shown in Google Chrome looks like this:

{"version": "1.1", "method":"progr","id":2,"params":{"call":...} }

It's about doing the call from (preferably) linux command line and retrieving the JSON content, not about parsing the incoming JSON data.

Answer

Pius Raeder picture Pius Raeder · Jul 19, 2011

You could use wget as well:

wget -O- --post-data='{"some data to post..."}' \
  --header='Content-Type:application/json' \
  'http://www.example.com:9000/json'