Pass cookie in http GET request jmeter

2019-08-02 10:23发布

问题:

Ideally, my request should be like this:

/oauth2/v1/consent?OCIS_REQ=asdfakdsfjsdfkjdfkjkdf 

Where "asdfakdsfjsdfkjdfkjkdf" is my Cookie

Im passing it as :

/oauth2/v1/consent?${COOKIE_OCIS_REQ}

But my "${COOKIE_OCIS_REQ}" Variable is not getting replaced with the cookie. Though I set the cookie in Header Manager and enabled CookieManager.save.cookies=true in jmeter.properties and passing it in HTTP Header Manager as
Name : Cookie Value : ${COOKIE_OCIS_REQ}

The request is simply going like : GET https://vkon.demo.internal.com:1111/oauth2/v1/consent${COOKIE_OCIS_REQ}

Cookie Data:

asdfakdsfjsdfkjdfkjkdf

Why my Variable is not getting replaced ?? I'm really fed up with this.

I tried passing it a parameter in request, User defined variable Also but no luck!!

回答1:

First, check what all Cookie variables are created by adding Debug Sampler and View Results Tree.

Then run the test and look at the Debug Sampler result in View Results Tree to check the Cookie variables saved as follows:

From the above image, it is clear that COOKIE_NID is created and can be used in other requests using ${COOKIE_NID} syntax.