Testing a REST API requires a client that consumes the REST API, users can then use the client to expose the particular HTTP method. In this post, I am presenting three tools using which one can Test the Rest API manually. These are Advanced Rest Client, Postman-Rest Client and Curl in Linux.
Content
Using Advanced Rest Client
Advanced Rest Client is a chrome extension using which one can manually test a REST API.
How to get Advanced Rest Client-
- Go to Google Chrome’s Web Store
- Search for “Advanced Rest Client” or directly go here and Install the extension
- Once installed, click the “Advanced Rest Client” icon under chrome’s app section – chrome://apps/
How to use Advanced Rest Client
- One installed, launch the extension
- Enter the URL of the API in the URL textbox
- Select the radio button for the type of HTTP method to hit- e.g. POST
- Provide Headers (if required), in the Headers textbox
- Under Payload, pass the request body of the API in the form of key-value pairs e.g. {{“key1″:”value1″,”key2″:”value2”}
- Set the required content type e.g. application/json
- Hit the send button
You will find the appropriate response in the textbox below
Using Postman-Rest Client
Postman is also a chrome extension using which can be used to manually test a REST API.
How to get Postman-Rest Client
- Go to Google Chrome’s Web Store
- Search for “Postman Rest Client” or directly go here and Install the extension
- Once installed, click the “Postman Rest Client” icon under chrome’s app section – chrome://apps/
How to use Postman-Rest Client
- One installed, launch the extension
- Enter the URL of the API in the URL textbox
- Select the type of HTTP method from the method dropdown – e.g. POST
- Provide Headers (if required), in the Headers textbox
- For methods like Put, Post, etc provide input in the form of key-value pairs
- Set header params if required e.g. application/JSON
- Hit the send button
You will find the appropriate response in the textbox
Using Linux CURL
CURL is a command-line tool to send and receive data using various protocols like- HTTP, HTTPS, FTP, LDAP, etc. It comes by default with most of the Linux distributions. In order to test a REST API using curl we just need to hit the command for the appropriate HTTP method in Linux.
Typical Curl syntax for HTTP POST request (User can update the content header and other values as per the requirement)-
curl -v -X POST -HContent-Type:application/json --data-binary '{"param1":"value1", "param2":"value2"}' http://<ip>:<port>/API_URL
Curl syntax for HTTP PUT request-
curl -v -X PUT -d param1=value1 -d param2=value2 http://<ip>:<port>/API_URL
Curl syntax for HTTP GET request-
curl -v -X GET "Accept: application/json" http://<ip>:<port>/API_URL
Curl syntax for HTTP Delete request-
curl -i -H -X DELETE "Accept: application/json" http://<ip>:<port>/API_URL