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,490 points
1,057 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
4,111 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,300 points
22,391 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,460 points
1,251 views
0 votes
0 answers

Send private message to Discord user using bash and linux AT command

I'm running a Discord bot written in ...READ MORE

Apr 25, 2022 in Linux Administration by Edureka
• 13,690 points
1,295 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
1,208 views
0 votes
2 answers

Install postgreSQL on Ubuntu

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

answered Nov 12, 2020 in Database by Prachi
• 140 points
1,305 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
858 views
0 votes
1 answer

copy and create destination directory using bash

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

answered Jul 16, 2019 in Linux Administration by Upasana
• 8,620 points
921 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
2,876 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP