Send custom HTTP Header for external URL
Hello, We have a requirement to send a custom http header for authorization for an external URL using a JWT. I have tried running a custom Activity with OOTB pxGenerateJWT and java code to "setHeader(token, authToken) before the Open URL in Window action but am having trouble getting the custom http header passed with the URL. I am not sure what is the best way to achieve this. I have seen several similar questions asked on Pega Support Center but none that actually seem to have been solved with a resolution. Does anyone have any ideas on the best way to accomplish this? I appreciate any assistance. Thank you!
String token = "Token";
String authToken = "<token>";
String DocumentURL = "<test url>";
PublicAPI tools = pega_rules_utilities.getPublicAPI();
org.apache.http.impl.client.CloseableHttpClient 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();
try{
org.apache.http.HttpResponse response = client.execute(request);
}catch(Exception e)
{
System.out.println("exception in setting header");
}