Discussion
Send custom HTTP header
Hi,
We have a requirement to send a custom header for authorization, for example a header with name "token". This needs to work seamlessly together with the action "Open URL in Window" that is available for links in a Repeat Grid.
We've tried adding a extra action "Run Activity" before the Open URL in Window, that will run an activity with this Java code:
String token = "";
String authToken = "$2y$10$.vGA1O9wmRjrwAVXD98HNOgsNpDczlqm3Jq7KnEd1rVAGv3Fykk1a";
client = org.apache.http.impl.client.HttpClients.custom().build();
org.apache.http.client.methods.HttpUriRequest request = org.apache.http.client.methods.RequestBuilder.get().setUri(DocumentURL).setHeader(token, authToken).build();
response = client.execute(request);
Like you see in the code above, we set the custom header with "setHeader(token, authToken)", but once we click the link, we notice* the custom header is not being passed over to the DocumentURL we specified...
*We used Firefox's Live HTTP headers extension to monitor the header information that is being sent over
Since I think Pega 7.1.8 does not have a OOTB way to send custom HTTP headers... Any idea for a workaround for this problem?
Thanks,
Jose
I tried to do a XHR request inside a HTML rule, but it failed to execute… I used Firefox’s Network tool to monitor the traffic and headers information. I noticed that only a POST request (related to my activity that gets executed) is done when you click the link. The GET request inside the HTML rule gets ignored... The code I used for the XHR request is the following:
Thanks for any ideas or help in this topic :)