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 Ian@APImetrics.com!

Sign Up to Our Newsletter

Want to be updated on latest API Metrics Insights? Sign up to our newsletter and receive latest news and blog from us.

Add an API

Related Posts

Join Us Now!

Join the 100s of companies relying on APImetrics.
Share