Gibberish text from API
Question
Application Type
Reactive

Hi all,

I need some suggestions on the response on one of the API.

This is the output of the API:

It should be a ZIP file (Binary) that contains the records.txt file, but when I tried the API, it returned gibberish text. Initially, I used text to binary to convert (with encoding "utf-8/utf-16/Unicode/ASCII") and download it for display purposes, but I could not extract it due to data error. Any advice would be very much appreciated. Thanks!

Note: it returned octet-stream instead of json. I copied the response and it returned as plain text...

I've also looked into https://www.outsystems.com/forums/discussion/16634/rest-encoding-problem/ but still couldn't solve the issue.


Any advice on the encoding in BinaryDataToText? Thanks again.

Regards,

Kenny

mvp_badge
MVP
Solution

Hi Yung Shin,

The data you receive is actually binary data (you can see it starts with "PK" which is a ZIP file's signature), so a Response Format should be set to Binary, not Plain Text. There should be no conversion to or from Text, since this is a ZIP file. Instead you should use the ZIP Extension Actions like LoadZip to handle it.

Hi Kilian,

Thank you so much! It worked! Before this, I used the 'Copy to Response Body', expecting it to create the Output automatically but it doesn't work that way, new stuff for me to learn ??. Thanks again!

Regards,

Kenny

mvp_badge
MVP

Hi Yung Shin,

Glad I could be of help! Happy coding :).

Hi Kilian,

I've one side question. The image below is the text that I've stored in the table, but when I try to retrieve from the table, it became two double quotes as the second image below.

1.

2.

I've tried to replace the double quotes with Replace(Text, """""", """"), as mentioned by you in another post but it doesn't work properly. These are just the dummies that we're testing to locate the issue with the API because we're passing the text with double quotes into the URL of the API and it returns an error (400). Although it is working fine in the API testing when we pass the text as the URL.

For example, the API is https://example.com/?filter=(selected=={abcdef};status=="{TEXT}")
When we test with the GET API, it is working properly. But when we pass the text as an input parameter of the API, it returned an error.

mvp_badge
MVP

Hi Yung Shin,

Don't be fooled by the way Service Studio displays double quotes inside a string, as it wil always use two double quotes to denote a single one. It's the same when you enter double quotes in a Text variable, two = one. So if Service Studio, for example in the debugger, shows that a Text variable has the value

"my ""value"" is this"

then that variable actually holds the value

my "value" is this


I see, thanks for the clarification. Our actual problem lies in the API itself, should not be affected by the Text, will look into it again. Thanks again for your prompt assistance!

Regards,

Kenny

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