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)?
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 RegardsThibaut
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/
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
I have a header in an APIThat header when not needed is left empty, but instead of returning an empty header I want to not share the header at all.
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
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 thereFor the exposing APIs, you can set the input parameter as not mandatory and consumers could either send it or notApologies for the mess and hope that it helped now, if it didn't please let me know
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
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.