Question
Sytel Reply
IT
Last activity: 11 May 2023 9:17 EDT
Handling Header of Custom and OOTB REST Service
Hi everybody.
I want to start a discussion and understand better how can we manage the header of a Service.
In this example let's have a totally custom REST service I made on Pega. Now I'd like to analyze its header in order to get meta information about the one who's invoking my service (e.g. correlation ID, authentication, or just any custom information we can have on header). For custom service we have on the section header where we can memorize in the property all the information we want. That's good because we can customize all we want.
Now let's have an OOTB service (e.g. DX API, both v1 and v2). Now for these kind of services, since the rule is created by Pega and not custom, is a Final rule. This means I cannot edit. So I cannot add in the service rule another header.
So I've made my research and I found a snippet online: (javax.servlet.http.HttpServletRequest)tools.getRequestor().getRequestorPage().getObject("pxHTTPServletRequest")
where this pxHTTPServletRequest has the list of all request passed. So basically I can create a Java function that allows me to execute a for each element and look for the header element I'm looking for (if this is a Java step of an activity or a function I believe is the same, but I'm looking for a confirm about this).
Since I cannot edit the service REST rule, nor the activity, in which way can I retrieve the headers? And which rule are involved in those edit.
Hi everybody.
I want to start a discussion and understand better how can we manage the header of a Service.
In this example let's have a totally custom REST service I made on Pega. Now I'd like to analyze its header in order to get meta information about the one who's invoking my service (e.g. correlation ID, authentication, or just any custom information we can have on header). For custom service we have on the section header where we can memorize in the property all the information we want. That's good because we can customize all we want.
Now let's have an OOTB service (e.g. DX API, both v1 and v2). Now for these kind of services, since the rule is created by Pega and not custom, is a Final rule. This means I cannot edit. So I cannot add in the service rule another header.
So I've made my research and I found a snippet online: (javax.servlet.http.HttpServletRequest)tools.getRequestor().getRequestorPage().getObject("pxHTTPServletRequest")
where this pxHTTPServletRequest has the list of all request passed. So basically I can create a Java function that allows me to execute a for each element and look for the header element I'm looking for (if this is a Java step of an activity or a function I believe is the same, but I'm looking for a confirm about this).
Since I cannot edit the service REST rule, nor the activity, in which way can I retrieve the headers? And which rule are involved in those edit.
One I can think about is the authorization of the service package, but it seems a little too much. Because it's true that in the Authentication Service it's possibile to insert the java part, but then you have also to handle all the authorization of the service. So I'd like to discuss about this in order to see if there's a smart way to handle the header of a OOTB REST Service, or is something I did not understand and so I gladly ask you if you can enlight me.
Thanks everyone.
Have a nice day,
Daniele
***Edited by Moderator Marije to change Type from Discussion to Question***