JMeter Tool

The Apache JMeter is purely a Java based open source application, which is designed to measure performance and perform load test. Over the years, the usage of JMeter has been expanded to other testing areas of a Web application.

The Apache JMeter tool can be used to test a REST API or Web service. In addition, you can send the Json request and parse its response.

REST Web Service: Test Plan

To perform the JMeter test, you need to first create a Thread Group with a sampler HTTP request, as shown below.

How to Test Representational State Transfer (REST) Style Based Web Services?

Note: In the above step, the header request might expect ‘Access’ and ‘Content-Type’ parameters. As a result, you may get an ‘Unsupported Media Type’ response message or a response code of 415. You can click on the ‘View Results Tree’ option on the left pane to see the response.

How to Test Representational State Transfer (REST) Style Based Web Services?In order to send the parameters in the request header, you need to add an HTTP Header Manager and send request headers in the form of “Content-Type’ and ‘Access’ variables, as shown below.

How to Test Representational State Transfer (REST) Style Based Web Services?

How to Test Representational State Transfer (REST) Style Based Web Services?

You need to use an API key to register your application. This can be done by sending it in the request body as a POST method, as shown below.

How to Test Representational State Transfer (REST) Style Based Web Services?

The response should be in Json format, as shown in the figure given below.

How to Test Representational State Transfer (REST) Style Based Web Services?

Json response can be parsed or extracted using different methods, including the JsonPath plug-in. Once done, you can use the Json Path Extractor, as shown below.

How to Test Representational State Transfer (REST) Style Based Web Services?

After adding this to the test plan, you can reference the Json elements using dot notation. For example, in order to get the value of the ‘client_id’, refer the image shown below.

1How to Test Representational State Transfer (REST) Style Based Web Services7 (2)The variable by the name ‘client_id_value’ will save the value of the ‘client_id’. However, you can assign any other name of your choice.

After the value has been saved, you can use the variable name in the form ${client_id_value} to recall the value, as shown below.

How to Test Representational State Transfer (REST) Style Based Web Services?