Using the REST API, we will be posting data as a JSON object. And we will add to this sampler to the Thread Group. We will then pass our token via HTTP Header Manager. So we add one more “HTTP Request” Sampler and configure with “JSON” type credential info. The system will give the us authorization token that we need to extract and pass into the next request. We understand from this error message that we have to successfully log in to the system first. Most of the Rest API’s require authorization because of security issues. This is because our Rest API needs to be authorized. Once we run the script, we see that the server rejects the request with a “401 Unauthorized” error. Our example is getting the active SIM number from the web service.
![apache jmeter rest api load testing apache jmeter rest api load testing](https://miro.medium.com/max/1400/1*sAgBTKVArcbveAqvRRJNeg.png)
We enter our Rest API request with “JSON” format in the “Body Data” section. This will help to us with which token we should extract.Ĭonfigure the HTTP Request Sampler to send a Rest API request. Adding an HTTP Request to the Thread Groupīefore starting configuration, add the View Result Tree Listener. It will give us the token and we will pass it in the subsequent request. To perform this authentication, before sending the request, we have to send a prior login request with the right credentials. You will most likely receive an error from the server: “ 401 Unauthorized” because almost every REST API requires some authorization process. Let’s imagine you want to measure your Rest API request with JMeter and configure the request using JSON format and click the run button. We will see that HTTP Headers play a crucial role in access authentication. In this guide, we are going to test REST APIs with authentication using JMeter.
![apache jmeter rest api load testing apache jmeter rest api load testing](https://champsoftblog.com/wp-content/uploads/2020/12/jmetr-bat-file.png)
![apache jmeter rest api load testing apache jmeter rest api load testing](https://apisero.com/wp-content/uploads/2020/07/8-30.jpg)
They are also frequently being used in Microservices. Rest APIs are increasingly popular these days.