1
votes

I have been asked to test my Rest API in JMeter and configured my service details in HTTP Request tab in JMeter and unfortunately i am seeing Authentication failed error even though it displays correct information in Request tab.

enter image description here

enter image description here

Here is my Header Manager section as below...

enter image description here

This is my request and using POST method for this.

enter image description here

Can you pls help in getting this fixed...

2
Which method you are using GET or POST? Please post the HTTP request snapshot.NaveenKumar Namachivayam
Hi Naveen, I have added request image in the post.Thanks,R K
Thanks @Ram Karlapudi. Couple sanity things. Make sure you are using valid JSON. You can validate it using jsonlint online tool. Also, every time token will expire. You need to extract the token from the first request and pass it in the subsequent request. Let me know if you need any help. :)NaveenKumar Namachivayam
Thanks for quick reply Naveen. Yes JSON is correct Naveen. I need a help in extracting the token from request..Can you help me ..R K
Yes Sure. Let me check to create a chat.NaveenKumar Namachivayam

2 Answers

0
votes

you have to implement correct correlation.
Authentication must be executed every time.
The authorization token is a random value that you get from previous authentication. You have to extract it (maybe with a regular expression) and use it in the HTTP operation.

0
votes

The recommended way of testing resources protected by Basic HTTP Authentication is using HTTP Authorization Manager.

  1. Add HTTP Authorization Manager to your test plan
  2. Provide Base URL and credentials (plain text)

That's it, you don't need to add Authorization header manually, JMeter will automatically generate it, check out How to Use HTTP Basic Authentication in JMeter article for more details if required.