Question

Map Set-Cookie header in Connect REST response

SUPPORT ARTICLE

https://community.pega.com/support/support-articles/map-set-cookie-header-connect-rest-response

I Used Pega 7.3.1 the problem remained.

In pyInvokeRESTConnector activity updated step: call tool.invokeConnector.

How to get all values from Header Set-Cookie?

***Edited by Moderator: Lochan to update platform capability tags***

Comments

Keep up to date on this post and subscribe to comments

Pega
October 15, 2019 - 7:09am

Hi ,

Have you tried changing the pyInvokeRESTConnector ?

By default you will be able to retrieve the last header. Have you tried adding a logic to retrieve the first and last header and assigning it to different variables?

How many header param are you tryinf to retrieve the from the httpResponse?

Thanks,

Nithin

October 22, 2019 - 2:41am
Response to thaln

Thanks thaln for the answer.

 

I need all headers with the name Set-Cookie.

I solved my problem as follows:

1) began to use HttpConnector

2) slightly corrected InvokeHTTPConnector - the third step:

try

            {

                //curHeader = httpResponse.getLastHeader(headerName);

              // FIX. CLAIM. Map Set-Cookie header in Connect REST response

              com.pega.apache.http.Header[] responseHeaders1 = httpResponse.getAllHeaders();

                for (int z = 0; z < responseHeaders1.length; z++){

                if(responseHeaders1[z].getName().equals(headerName))

                {headerVal += responseHeaders1[z].getValue();}

              }

            } catch (Throwable t)

            {

                curHeader = null;

                oLog.warn("Caught throwable when attempting to get \"" + headerName + "\" header  from response", t);

            }

            // BUG-157631: avoid attempts to obtain the value of a null header.

          // FIX. CLAIM. Map Set-Cookie header in Connect REST response

            if (curHeader != null && (headerVal == null || headerVal.trim().length() == 0))