NEW data on the problem of API drift – most production APIs are not built as designed  Learn more >

Cookie Authentication

We support Cookie Authentication using the Post-Conditions section of a test, in conjunction with a multiple-test test run.

The general idea would be a test run with the follow:

  1. Call an API which creates the session
  2. In the Post-Conditions, extract cookie value in post-conditions
  3. Call other tests, add a header using the custom variable from (2).

For example, if your API returns a header:

200 OK

Set-Cookie: ASP.NET_SessionId=zw4ixeriskyukm5asrdh0nlv; path=/; HttpOnly

In Post-Conditions, add a variable under headers named COOKIE, with the following path:

Set-Cookie|replace(‘; path=/; HttpOnly’, ”)

 

Then in the follow-on tests, add a header in the test setup page:

Cookie: %%COOKIE%%

 

If you need any further assistance with this. Please post a comment, or contact us to [email protected]

Share

Request A Demo

Find A Slot To See A Demo Or Speak To One Of Our Support Specialists

Ready To Start Monitoring?

Want to learn more? Check out our technical knowledge base, or our sector by sector data, or even our starters guide to the API economy. So sign up immediately, without a credit card and be running your first API call in minutes.

Related Posts

Join Us Now!

Join the 100s of companies relying on APIContext.