Highlighted
New Member.
886 views

UFT and REST server, passing cookies to next

Hi guys,

I'm having a weird problem, I'm trying to create a simple script that will issue a login and logout on a REST server. This server utilizes cookies for the authorizations, this mean that, when I login the server generated a cookie with a unique ID, then this ID has to be passed in the header of the next commands to be executed (validating that it's still me and I'm logged in already), the login returns a "HTTP 204 – NO CONTENT" when is successfull, is there a way (without coding the entire script) to save the cookie ID in a variable and pass it to the next command in an header? I've tried to create a JSON file with the "possible response" (I don't have it so had to guess based on the response the system gives when logged in) to then pickup the ID and put it in a variable that is then passed to the next commands, but this doesn't work.

To explain myself better, what I'm looking for is a way to save the cookie ID given from the login:

Step 'HTTP Request15' : HTTP Raw response:

Step 'HTTP Request15' : HTTP/1.1 204 No Content

Content-Length: 0

Set-Cookie: id=0cc779b8-2131-4c03-955a-65a69bd7bc51; secure

Checkpoint 0: "204" = "204" passed

Step 'HTTP Request15' ended successfully

 

And then pass this variable to other commands.

Is it possible?

Thank you

0 Likes
2 Replies
Highlighted
Contributor.. Contributor..
Contributor..

I am currently looking into doing the same thing, have you found a way to do it?

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Domenico_V,

Not sure if you still need this, but yes, this is possible.
Check this out:
https://community.softwaregrp.com/t5/Unified-Functional-Testing/UFT-Support-tip-How-to-handle-cookie-based-authentication/td-p/1631981

Regards,
Alvaro

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.