Hi All,

I have tried searching the message boards and googling my issue and can not find anything that works for me. So here goes;


I have a webservice that requires JSON saved as binary. I the data I need to send to the webservice i am pulling from an external entity (Azure database). The data that come back from the database is of record list type.

When I put this though the JSON serialize the result is not in "proper" JSON, It has double quotes where there should be single quotes and there is a starting as trailing double quote.

I understand that this is how Outsystems represents the JSON, however the issue I have is that I need to convert this to binary and send to the webservice. The webservice therefore does not understand the input. I am not sure if I am doing something wrong or if i need to put the output though a Regex find and replace?

Any nudge in the right direction would be appreciated.


Thanks


Lee

Hi Lee,

The double quotes which you are observing while debugging the code would not be a problem because it gets removed automatically when we assign/copy the JSON.

For converting the text to Binary, Outsystems provide the action "TextToBinary", which can be found under "BinaryData" extension in Manage Depenencies.

Pass your text and the action will return the binary data which can be used as per requirement.

Hope this helps you !!

Regard's,

Lakshmi Kumar Yadav

Hi Lakshmi,

Thank you for the reply.

It must be another issue I am having then. Is there a way that I can open up the binary outside of Outsystems so I can see exactly what the JSON looks like that being sent?

Thanks

Lee

Hi Lee,

As per my knowledge, i don't have the exact idea about how this would be done from the outside of outsystems, may be other community members can help you for sure over this, but you can use some "Binary to text translators" methods which can convert the binary to text.

In Outsystems, if you want then you can use the "BinaryToText" action which will convert the binary data to text and you can see the exact JSON.


Thanks,

Lakshmi Kumar Yadav

HI Lee,

You can write the Binaries in a file using File extension (see below) and than can convert the binary data of the file into text to see what is being transmitted to your API.

For online conversion of Binary to text you can refer this link (https://codebeautify.org/binary-to-text


Let me know if you think it helps :)

Regards,

-PJ-


Hi Lee,

I think the replies above have answered your questions, but since I'm a fan of tl;dr:

  1. The JSON the debugger shows is just the OutSystems representation of a Text Variable. The double double quotes aren't really there in the string.
  2. All plain text is a subset of a binary format. TextToBinary() converts a Text Variable into a Binary Data Variable, but for plain text there's actually no conversion in the underlying bytes! Only when using things like letters with accents or Chinese characters or the like there's a difference between the text and its binary representation.

Given the above, a web service wanting "binary" instead of "text" doesn't make much sense. Can you share a description of the particular web service?