HTTP POST and GET using cURL

0 votes
So, I have a server app written in ASP.NET. How can I call the web service in Linux using cURL?
Jul 22 in Linux Administration by Shubham
• 13,290 points
16 views

1 answer to this question.

0 votes

You can just add | grep }| python -mjson.tool to the end of curl commands.

GET approach with JSON result

curl -i -H "Accept: application/json" http://someHostName/someEndpoint | grep }| python -mjson.tool 

POST approach with JSON result

curl -X POST  -H "Accept: Application/json" -H "Content-Type: application/json" http://som

Just add | grep }| python -mjson.tool to the end of curl commands here is two examples:

GET approach with JSON result

curl -i -H "Accept: application/json" http://someHostName/someEndpoint | grep }| python -mjson.tool 

POST approach with JSON result

curl -X POST  -H "Accept: Application/json" -H "Content-Type: application/json" http://someHostName/someEndpoint -d '{"id":"IDVALUE","name":"Mike"}' | grep }| python -mjson.tool

answered Jul 22 by Upasana
• 8,530 points

Related Questions In Linux Administration

0 votes
1 answer

How to perform proxy http request using curl?

One of the ways is: export http_proxy=http://your.proxy.server:port/ Then you ...READ MORE

answered Mar 26 in Linux Administration by DareDev
• 6,810 points
58 views
0 votes
1 answer

redirecting stdout and stderr to file using bash

cmd >>file.txt 2>&1 Bash always executes and redirects ...READ MORE

answered Mar 19 in Linux Administration by ajs3033
• 7,280 points
36 views
+1 vote
3 answers
0 votes
1 answer

Regarding Edquota soft and hard limits

The provided value for soft and hard ...READ MORE

answered Jan 3 in Linux Administration by Omkar
• 67,290 points
29 views
0 votes
1 answer
0 votes
1 answer

How do I set variable if a specific package version is installed in CFEngine?

Here is what you can do.Just use packagesmatching to ...READ MORE

answered Jul 12, 2018 in Other DevOps Questions by Atul
• 10,240 points
73 views
0 votes
1 answer

Install postgreSQL on Ubuntu

Installing PostgreSQL on Ubuntu is very simple, ...READ MORE

answered Mar 22 in Database by Nitesh
37 views
0 votes
1 answer

Access progrs prompt without switching accounts

Use the following to get the postgres prompt ...READ MORE

answered Mar 22 in Database by Mahi
23 views
0 votes
1 answer

copy and create destination directory using bash

mkdir -p "$d" && cp file "$d" try ...READ MORE

answered Jul 15 in Linux Administration by Upasana
• 8,530 points
20 views
0 votes
1 answer

To attach a file using mail command on Linux

$ echo | mutt -a syslogs.tar.gz admin@domain.org READ MORE

answered Jun 28 in Linux Administration by Upasana
• 8,530 points
39 views