44
Views
5
Comments
Solved
REST API OnRequest callback action is empty
Application Type
Reactive

I have exposed the GET REST API method, where i am trying to manipulate the input parameter of the request.

I set the "Receive In" property of the input parameter to "Header". In the OnRequest callback action, we received an empty "HTTPRequest" object. I do not know how to get the request header here. Because we get the input parameter value in the rest api method. 

Do i need to use any other extension method to get the input parameter header name/value in the OnRequest action? 

I have attached both screen shots for reference. 



OnRequest.png
RestAPIMethod.png
2019-03-19 12-24-07
Mariano Picco
 
MVP
Solution

Step 1: 

Give your input parameter,which is set to "Receive in Header" a "Name in Request":


Step 2: 

Add the dependency GetRequestHeader, from HTTPRequestHandler


Step 3:

On your OnRequest, add the server action GetRequestHeader somewhere, and tell it to fetch the Header with the same name as you've given it in your Step 1


That's it, you have the value of your header coming in. You can catch this in the debugger, for a test:

2022-05-18 07-58-50
Pradip Chavhan

Hi @Mariano Picco 

Thank you for the quick response, kindly elaborate the next step how can i assign the changed value or new value to the the header back.

Now here i changed the value of the header e.g. A-B now how i can add new value B to the header back.

Kindly elaborate it.

2019-03-19 12-24-07
Mariano Picco
 
MVP

Hi Pradip, 


To manipulate Headers before you reply to the request, I believe you'll need another action:


SetResponseHeader and use whichever Header name you want, and its value. 


2022-05-18 07-58-50
Pradip Chavhan

I am unable to find the HTTPResponseHeader extension. 

2019-03-19 12-24-07
Mariano Picco
 
MVP

That is odd. I checked on another environment and I can see the extension, I thought it was a default one that comes with OutSystems. It's not on the forge.

I logged on to other dev environments that I have access to, and 3/4 had the extension, 1 didn't. 

It is strange. Perhaps open a support case with OutSystems? 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.