Lwp-request in the shell: how to make a POST request with the body?

I am using a simple shell script to validate an HTTP server handling POST requests. Usually it looks like this:

echo "param1=value1&param2=value2" | POST localhost/service 

But now I want to pass also some json to the POST body and one where I will skip the point completely.

the POST man and google didn't help either.

It seems to be either very simple or absolutely impossible.

Thanks for the help.

+7
source share
2 answers

Either I'm missing something, or you need to

  $ echo -n '{"json": "data"}' |  POST -c "application / json" 'http: // localhost / service? Param1 = value1 & param2 = value2'

If you need to put these parameters not as GET, but as POST, then view data with several formats.

+4
source

You probably need to pass the content type using -c :

 POST -c application/json 
+1
source

All Articles