28
Views
11
Comments
What is purpose of exposed REST "Send in: Header" purpose because it does nothing!
Question

I am implementing an exposed REST API where I need to send a value in the "Location" header (and other headers but focusing on this one only) in the response. It is my first time requiring to add headers to response. This is the ID of the record that was created in the POST, as determined by the protocol I am implementing.

So I could not find any documentation about how to add headers in the response of an exposed REST. I saw that one can set an output variable on the REST action and select the attribute "Send In" to value "Header". From this then I gather it shall be sent in the Response Header, further once one selected the "Send In" value as "Header" the "Name in Response" becomes enabled, then I further will assume that here one then supply the name of the header, such as "Location" in this case. I did this and assign a value to the LocationHeader variablle inside the REST action, but nothing is returned in the response header.

Below is screenshot of my example.

Please if someone be so kind to explain to me:

1. The purpose of "Send In: Header" and the "Name in Response", because OutSystems documentation has nothing on this.

2. How to set the header of the response if one needs to, once again OutSystems documentation has nothing on this either (none that I was able to find after reading OS11 expose REST APIs documentation here the link below, which has minimal info and NOTHING on headers, we are to guess how to do this: https://success.outsystems.com/Documentation/11/Extensibility_and_Integration/REST/Expose_REST_APIs)



Rank: #606

Elize van der Riet wrote:

I am implementing an exposed REST API where I need to send a value in the "Location" header (and other headers but focusing on this one only) in the response. It is my first time requiring to add headers to response. This is the ID of the record that was created in the POST, as determined by the protocol I am implementing.

So I could not find any documentation about how to add headers in the response of an exposed REST. I saw that one can set an output variable on the REST action and select the attribute "Send In" to value "Header". From this then I gather it shall be sent in the Response Header, further once one selected the "Send In" value as "Header" the "Name in Response" becomes enabled, then I further will assume that here one then supply the name of the header, such as "Location" in this case. I did this and assign a value to the LocationHeader variablle inside the REST action, but nothing is returned in the response header.

Below is screenshot of my example.

Please if someone be so kind to explain to me:

1. The purpose of "Send In: Header" and the "Name in Response", because OutSystems documentation has nothing on this.

2. How to set the header of the response if one needs to, once again OutSystems documentation has nothing on this either (none that I was able to find after reading OS11 expose REST APIs documentation here the link below, which has minimal info and NOTHING on headers, we are to guess how to do this: https://success.outsystems.com/Documentation/11/Extensibility_and_Integration/REST/Expose_REST_APIs)



 

 Hi Elize 

Send in property you can inject a customised header in you Response.

I just created one and use SOAPui to test.

Evidence:

OS REST


Response (as you can see my customised header is there):

If you need any assistance just gimme a shout.

Regards 

Hi CM_Techy,


Thank you for the reply, but I think you did not understand my explanation. What you suggesting is exactly what I did, if you look at my example the output variable "LocationHeader" is set to be returned in Header on the "Send In" attribute, but note that it is a POST, and the "Location" is not returned in the response header.

I noticed that it works fine in a PUT, I have not tested GET yet, but as you showed it seems to also work in GET, so that implies it only does not work for a POST. But why does it not work on POST? If you test POST I am sure you will also find it does not work.

Rank: #129

Hi Eliza,


I have done this in the past and it was in the way you described. It worked back then and it worked now... except for the header named "Location".

My best guess is that "Location" header is ignored by OutSystems platform just like the "Connection" header is by design (see post here).


I would try to apply the workaround in the solution in the post (it was the answer from OutSystems support for the "Connection" header and I guess the same would apply to this one.


Best regards,

João Marques

HI CM_Techy,


This solution is not an option, I no have a header with a name not expected by the sender of the POST in the response, see screenshot, I called it "Content-Header-Location" and it came through but that is not the HTTP protocol defined "Location" as expected by the other end, so this is not an acceptable option.

Please be more clear how you achieved the POST to return the "Location" header as it is not clear how you did this.

OK, this is weird, after I tested the above by changing the Location name I changed it back and now it works, the POST does return the Location header in the response. I am now wondering if it was Postman that I am using to test with that had the problem not showing the Location Header for some reason and now it does? But it definitely now works.

I have the same problem now with the ETag header on the PUT, I added an ETag header and it is not coming through on Postman. I am wondering now if Postman is not the issue.


Thank you for your efforts, most probably if I could trace back what I id I will find the problem was PEBKAC :)