Input string doesn't have the correct length

Hello everyone,

I have a problem that I do not know how to solve and I need your help.

The confidential data in my application can not be stored in OutSystems DB and must be stored in a database table of the Customer where I am working for.

To save the information, I use a REST service in which the input is a JSON structure that I want to store in the Client Database. Before saving the information, I use the JSON Serialize on the structure with confidential information, then BinaryToBase64 (TextToBinaryData (JSON Serialized above))) to compress the information to save and lastly do the JSON Serialize again to the Request Data of the input REST Service .

The problem I encounter is when I read this information, via REST service, in which I do the reverse steps, and there is some reserved character that causes the error "Input string does not have the correct length".

This confidential information can be written by the user in an input data or by output of another service that returns information of a certain client.

Any idea on how to overcome this problem?

To Save Data:

To Read Data:


Ricardo Brito


Outsystems allows you to set an output structure when consuming RESTful services, you would not have to deserialize the JSON explicitly. You can check how to this in: 

This might solve your problem.



Hi João,

Thanks for your answer. I've set an output structure when consuming the service to Read Data that is the same structure in the input when consuming the service to Save Data, like this one:

{"Attribute1": "A",
"Attribute2": "2018-03-19T11:41:44Z",
"Attribute3": 4305,
"Attribute4": "ConfidentialStructure"}

Here is an example of my confidential information that I need to store in base64 for restrictions purposes:

"ConfidentialStructure": {
"Structure1": {
"Attribute1": 2,
"Attribute2": 4309,
"Attribute3": "2018-03-19T11:41:44Z"
"Attribute4": "9000422504",
"Attribute5": "2018-03-08",
"Sctrucure2": [{
"Sctrucure3": {
"Attribute6": 2,
"Attribute7": 4309,
"Attribute8": "2018-03-19T11:41:43Z"
"Structure4": [{
"Structure5": {
"Attribute10": "1",
"Attribute11": "2018-03-07",
"Attribute12": true,
"Attribute13": "020",
"Attribute14": "728",
"Attribute15": "0003",
"Attribute16": "21691555020",
"Attribute17": "ProductDescription",
"Attribute18": "0001-01-03"}}]}]}}

The Attribute17, is a text that could contain a reserved character that causes the error "Input string does not have the correct length" when I'm decoding the base64 ConfidentialStructure.

Correct base64 ConfidentialStructure stored in the data base:


Incorrect base64 ConfidentialStructure stored in the data base:



It's the same JSONbut with a "break" to emulate the error. Imagine that this "break" presented in the last json is a reserved character that is in the Attribute17.

Here is a screenshot of the method result after consuming the REST service to Read Data:

It's something wrong with it...


Ricardo Brito