Input string doesn't have the correct length

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:



Cheers,

Ricardo Brito

Hi,

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: https://success.outsystems.com/Documentation/10/Extensibility_and_Integration/REST/Consume_REST_APIs/Consume_a_REST_API 

This might solve your problem.

Regards,

João

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 Conf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sKIlNjdHJ1Y3VyZTMiOiB7CiJBdHRyaWJ1dGU2IjogMiwKIkF0dHJpYnV0ZTciOiA0MzA5LAoiQXR0cmlidXRlOCI6ICIyMDE4LTAzLTE5VDExOjQxOjQzWiIKfSwKIlN0cnVjdHVyZTQiOiBbewoiU3RydWN0

dXJlNSI6IHsKIkF0dHJpYnV0ZTEwIjogIjEiLAoiQXR0cmlidXRlMTEiOiAiMjAxOC0wMy0wNyIsCiJBdHRyaWJ1dGUxMiI6IHRydWUsCiJBdHRyaWJ1dGUxMyI6ICIwMjAiLAoiQXR0cmlidXRlMTQiOiAiNzI4IiwKIkF0dHJpYnV0ZTE1IjogIjAwMDMiLAoiQXR0cmlidXRlMTYiOiAiMjE2OTE1NTUwMjAiLAoiQXR0cmlidXRlMTciOiAiUHJvZHVjdERlc2NyaXB0aW9uIiwKIkF0dHJpYnV0ZTE4IjogIjAwMDEtMDEtMDMifX1dfV19fQ=="

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...


Cheers,

Ricardo Brito