Calling a REST API using CURL

In this post we will provide a few useful examples of calling a REST API using CURL. Using CURL for calling a REST API is useful when you want to, test a new service that you are creating, reproducing an issue you have seen on another environment or querying a service for some data.

Calling a REST API using CURL:

The following example shows a GET request:

The following example shows a POST request with a JSON body:

The following example shows a PUT request with a JSON body:

The following example shows a DELETE request:

If you want to use Basic Authentication then add the “Authorization” header for example:

I hope this post had some useful examples showing how to make REST calls using the CURL command.

Similar posts:

  1. Get request example in Java
  2. Rest PUT vs POST
  3. Post request example in Java
  4. Put request example in Java

References:

  1. CURL documentation

Leave a Reply