0

I am performing API testing using Jmeter, we have a API request which require authentication.

When I make a call http://localhost:3001/city/latitude/longitude (GET method) it returns User is not authorized. And to get authorization you require to call http://localhost:3001/user (POST method) passing username in json format.

So, how can I make a authorized call on http://localhost:3001/city/latitude/longitude

1 Answers1

1

It really depends on your app, but usually algorithm is like this:

  1. Call authentication method, in your case -

    http://localhost:3001/user (POST method) passing username in json format

    It will return some sort of authentication token as either a cookie (more common), or in the header, or as a response.

  2. You pass said authentication token with each following request. In case of a cookie, all you need is HTTP Cookie Manager. In case that token is returned in the header or as a response, you would need to extract it, save it as variable and then pass to each following request (of course you need to find out what is the name of the parameter or header to pass it as).
timbre timbre
  • 12,648
  • 10
  • 46
  • 77