Hi team,
How to fetch header "login-token" from response in java programmatically?
Thank you.
Solved! Go to Solution.
Views
Replies
Total Likes
Cookie[] cookies = request.getCookies(); if (cookies != null) { for (Cookie cookie : cookies) { if (cookie.getName().equals("login-token")) { //do something //value can be retrieved using #cookie.getValue() } } }
request.getHeader("login-token");
Thanks for the prompt reply Arun,
I have done that but not able to find the cookie "login-token" from response.
I am trying to hit Assets api using java code with access token .. getting 401 unauthorised, But in postman I am able to fetch api because In the header field login-token cookie is there in postman.
even when hitting assets api with basic auth also getting 401 unauthorised.
@sriram_1 hi,
If you are using java.net.URLConnection, you can use :
conn.getHeaderField("login-token");
If you are using Apache HTTPClient , you can use :
response.getFirstHeader("login-token").getValue();
Thanks,
Milind
Hi miland,
I have used the same but there is no header field named "login-token" in response.
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies