Advertisement
Advertisement


HTTP POST and GET using cURL in Linux


Question

I have a server application written in ASP.NET on Windows that provides a web service.

How can I call the web service in Linux with cURL?

2019/02/25
1
367
2/25/2019 10:28:02 AM


I think Amith Koujalgi is correct but also, in cases where the webservice responses are in JSON then it might be more useful to see the results in a clean JSON format instead of a very long string. 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

enter image description here

2019/10/01