55
Views
8
Comments
Hide header if empty REST API
Question

Hi All, is there an easy way to remove/hide a header if the value of the header is empty inside a REST API (regardless if im consuming or exposing)?

2025-12-15 09-29-24
Thibaut G

You can manipulate the Structures(including header attribute) in the OnBeforeRequest and OnAfterResponse.
Can you elaborate on 'hiding the headers'? i'm not sure if i understand

Kind Regards
Thibaut

2024-03-14 12-00-57
Carlos Costa

Hello André,
According to OutSystems documentation it's not possible to remove existing headers. https://success.outsystems.com/documentation/11/extensibility_and_integration/rest/consume_rest_apis/simple_customizations/


But there's a workaround, using OutSystems REST Extensibility API .

The following documentation might help with what you need:
https://success.outsystems.com/documentation/11/extensibility_and_integration/rest/consume_rest_apis/advanced_customizations/

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

Why is this down voted? the reply is actually the correct answer:

You cannot do it with basic authorization, but you can with advanced customization.

I just gave an up vote to compensate the down vote

2018-08-04 18-19-00
André Pinho

I have a header in an API
That header when not needed is left empty, but instead of returning an empty header I want to not share the header at all.

2024-03-14 12-00-57
Carlos Costa

Yes, you need to create an extension to handle the headers (in your case to remove them) because outsystems by default doesn’t have that functionality (according to the documentation sent above). 


I’ll try to create an example and send it here asap 

2024-03-14 12-00-57
Carlos Costa

André, apparently there's an easy solution if you are not running a personal environment. You can configure on the Factory Configuration module the following:And then let's say that you are consuming an API (Chuck Norris api) whenever the User-Agent (which is one of the headers) is equal to for example "Your-App" you want to remove it from the headers, then you can use the onBeforeRequest and perform the removal of the header in there

For the exposing APIs, you can set the input parameter as not mandatory and consumers could either send it or not


Apologies for the mess and hope that it helped now, if it didn't please let me know

2018-08-04 18-19-00
André Pinho

thanks Carlos good find, this works for a consume API.

Any idea how to implement this for a Chuck Norris expose API (where we don't have the header inputs to the onbeforerequest, in fact its called onbefore/onresponse).
The use case I have is a pagination header that contains the link to the next page. When the pagination finishes I wanted to remove the header as leaving an empty 'link' header according to RFC-8288 this is not allowed as it should be a valid URI https://datatracker.ietf.org/doc/html/rfc8288#section-3 

2018-08-04 18-19-00
André Pinho

Any idea on how to handle the header on a Expose API rather than a consume API?
Looks like we only get access to the responsetext/responsebinary.

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