I need to extract the SESSION id from the Set-Cookie. I want to use the XML method for variable extraction. This is the RAW text from the response that I need to extract the SESSION id:
HTTP/1.1 302 Found Date: Mon, 04 Jun 2018 23:28:41 GMT Content-Length: 0 Connection: close Server: Apache-Coyote/1.1 X-Content-Type-Options: nosniff X-XSS-Protection: 1; mode=block Cache-Control: no-cache, no-store, max-age=0, must-revalidate Pragma: no-cache Expires: 0 Strict-Transport-Security: max-age=31536000 ; includeSubDomains X-Frame-Options: SAMEORIGIN Set-Cookie: SESSION=28912d6b-4d75-42bf-8bc6-8f19f56cd7b0; Path=/linkos/; Secure; HttpOnly Location: somewhere.com
This is the flow we are trying to produce:
/scantoprint (virtual proxy endpoint)
We need to collect 5 things, place them in the formData of the virtual endpoint:
Individually, using Postman, it works using our PPME proxy endpoints. We use both printer endpoints, and manually copy the session id from one cookie to the header of the other. However we need to be able to do this in APIGEE as a proof of concept
Solved! Go to Solution.
Welcome to the community !! I am assuming you are referring to the Extract Variable policy. If yes, then the policy code can be something like this
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ExtractVariables async="false" continueOnError="false" enabled="true" name="Extract-Cookie"> <DisplayName>Extract-Cookie</DisplayName> <Properties/> <Header name="Set-Cookie"> <Pattern ignoreCase="false">SESSION={cookie};*</Pattern> </Header> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> <Source clearPayload="false">response</Source> <VariablePrefix>respPrefix</VariablePrefix> </ExtractVariables>
Once this is executed, the session ID should be available in a variable called "respPrefix.cookie"
Let me know if this works