1

I'm automating email verification process, For that I have an API where I have to pass the emailID with the URL e.g.http://apiqa.somewebsite.in/api/v1/verify-email-qa/narendrarajput@gmail.com and have to pass the rcAuthToken as parameter.

I'm Stuck somewhere how do I extract that token from Header ?

My use-case are - First, call the authentication API and store the header response and then extract the rcTocken from there and then pass it as parameter to the above as POST API request and then get the desired response.

Am I on right track ? Please help if there is convenient way.

1

The most convenient way would be using a specialised framework for API testing, you can consider RestAssured if you don't have any better alternatives.

Extracting response header would be as simple as:

Response response = get("/your/url");
String rcAuthToken = response.getHeader("rcAuthToken"); 

More information:

0

Yes you are on the right track.

I use HttpClient. HttpPost to be exact.

You can initialize the token as a static String outside the Post to authentication service method then run the Post to auth request. When you extract the token from the response that comes from the auth request, save it as the as the static String you had initialized above. Once that token gets stored, then you can call the token for the email service or any other service at test if they share the token. If they don’t share the token then you basically follow the same steps above per service.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.