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, 2019 in Linux Administration by Shubham
• 13,480 points
314 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, 2019 by Upasana
• 8,620 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, 2019 in Linux Administration by DareDev
• 6,890 points
2,643 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, 2019 in Linux Administration by ajs3033
• 7,280 points
1,116 views
0 votes
1 answer

How to create HTTP user using htpasswd command?

Hi@akhtar, Htpasswd command is available in the Linux ...READ MORE

answered Dec 2, 2020 in Linux Administration by MD
• 95,160 points
84 views
+1 vote
3 answers
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
299 views
0 votes
2 answers

Install postgreSQL on Ubuntu

Follow the below commands to install PostgreSQL (PSQL) ...READ MORE

answered Nov 11, 2020 in Database by Prachi
• 140 points
261 views
0 votes
1 answer

Access progrs prompt without switching accounts

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

answered Mar 22, 2019 in Database by Mahi
182 views
0 votes
1 answer

copy and create destination directory using bash

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

answered Jul 15, 2019 in Linux Administration by Upasana
• 8,620 points
157 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, 2019 in Linux Administration by Upasana
• 8,620 points
1,090 views