Hi @arghya das
I am getting response headers from Service Call out like below
[Set-Cookie: AUTHN_TOKEN=eyAidHlwIjogIkpXVCIsICJhbGciOiAiUlMyNTYiLCAiY3R5IjogIkpXVCIsICJraWQiOiAiMjk4MTNmNmYtNTEwNS00MTJkLTk5ODAtNzJhYTcyMGJlNzI0IiB9.eyAidG9rZW5OYW1lIjogImlkX3Rva2VuIiwgImF6cCI6ICJrcm9ub3MiLCAic3ViIjogIlN1cGVyVXNlciIsICJhdF9oYXNoIjogIi1JWDd3blRJX2VtV3Q5OV9WV0xFYnciLCAiaXNzIjogImh0dHA6Ly9hdXRoMi5mYWxjb24ua3Jvbm9zLmNvbTo4MC9vcGVuYW0vb2F1dGgyIiwgImlhdCI6IDE0NTE0NTEwMDUsICJhdXRoX3RpbWUiOiAxNDUxNDUxMDA1LCAiZXhwIjogMTQ1MTQ1MTYwNSwgInRva2VuVHlwZSI6ICJKV1RUb2tlbiIsICJyZWFsbSI6ICIvIiwgImF1ZCI6IFsgImtyb25vcyIgXSwgIm9wcyI6ICJmNWNC0xOTdmLTRlZjQtOTllYi0yZTc2ZWY3ZmQ1OWQiIH0.cctZGkZNsV5dKQTfndVhKwPnCKXmziYBi2aNO_gDQ_xFxgexkL8P2Tm53sF-aYU_XyerohWskMtknTjrAq4mANMgpgeMzi79FEzVBDaqLcvO6YYhx8IdS3pLhdAQwKk9h4lI3JGMtY8rlPW-6atkduh8sc1n-Ut6G4oBbxLnokFvpH7IT7mw3Jq1OMZVmFC2fZLPZMhD1MSqA1Mh_m3KBaxpaopqseC7eB7xpNOAl1JeJ3sHVnISQouUYN1E00Gi5_ZeXd8b02T0yq6DSywJ0ykmHwKw-gSNWhX6MyEg2DIBOqH4JVM9_uBciWsHpzH7oxf2pIvqfiIw3hsZwtbqwQ; Domain=.kronos.com; Path=/
, Set-Cookie: JWK_URI=“http://test.domain.com/openam/oauth2/connect/jwk_uri”; Version=1; Domain=.test.com; Path=/
, Set-Cookie: amlbcookie=01; Domain=.test.com; Path=/
, Content-API-Version: protocol=1.0,resource=2.0 , Date: Wed, 30 Dec 2015 04:50:05 GMT
, Accept-Ranges: bytes
, Server: Restlet-Framework/2.1.7
, Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept
, Cache-Control: no-cache, no-store, must-revalidate
, Pragma: no-cache
, Expires: 0
, Content-Type: application/json;charset=UTF-8
, Content-Length: 139 ]
If you see it has multiple “Set-Cookie” headers but when I am trying to parse Cookie header in javascript and set it in request header to targetendpoint as you suggested, it sets only first “Set-Cookie” header and ignore the rest of “Set-Cookie” headers.
Is there a way, I can parse all the “Set-Cookie” headers coming in response from Service CallOut and set it in a request header cookie ?
Also is it possible to do this with any other available out of box policies without javascript policy?
var headerNames = context.getVariable(“calloutResponse.headers.names”) + “”;
print("Header Names >>>>>>>>>>>> "+headerNames);
headerNames.split(", ").sort().forEach(function(headerName) {
if (headerName)
print(headerName+" : "+context.getVariable(“calloutResponse.header.”+headerName));
if (headerName == “Set-Cookie”)
context.setVariable(“request.header.cookie”, context.getVariable(“calloutResponse.header.”+headerName));
});