250
Views
3
Comments
Handling Content-Encoding : gzip - OData REST API Call 
Question

Hi all,

When calling an OData REST API, Product Master (A2X) from the SAP API Hub, we receive a response with Header Field: Content-Encoding: gzip. The body of the response is unreadable because Outsystems seems unable to handle the Content-Encoding: gzip.


However, according to Outsystems Patch update 11.6.32 states:
"Up until now, to support GZip encoded responses, the programmer need to write custom code. As It’s a common practice to use encoding in REST calls, the platform now allow this easy integration without having to develop extra code (RSBO-1137)"

Is there a way to read the body properly without having to develop extra code?

This doesn't seem to happen in all api's from the SAP API Hub though.

Thanks in advance!

ODataReactLIBProductMasterA2X.oml
UserImage.jpg
João Victor Velano de Sant'ana

Oh and a copy of a screenshot of the body response!

ODataRestApiweirdResponse.PNG
2020-12-17 16-46-21
Daniel Soto

I had the same problem. 

Use another tool like postman to do the request. Then copy the response and paste it on the body of your Rest Api call in Outsystems. 

Use this component https://www.outsystems.com/forge/component-overview/8684/gzip-compress-decompress in  "On After Response" to decompress the gzip (see image attached). Assign the output text to CustomizedResponse.ResponseText

It worked for me.


Regards

OnafterResponseGZIP.JPG
2021-09-08 08-01-41
Lorena Sabou


Hey Daniel, I'm trying to do the same now but I keep receiving System.IO.InvalidDataException: Found invalid data while decoding (in OnAfterResponse). Have you experienced this while implementing your solution?

Is the response of your API defined as a JSON, or binary?

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