I've created a new rest api based on JSON input.
When called from the external system I see the following error in the integrations logging:
Failed to parse 'auxinParamRequest.value.data.employee.contract.position.id': Unable to translate bytes [F6] at index 12 from specified code page to Unicode.
When I take the input from the logging and call the rest api via Postman it works fine.
The data is delivered in UTF-8 format. But no matter how change the character set it seems to work fine via Postman.
What kind of steps can I take to find out what the problem is? Any ideas?
Hello Cees,
Is the value you are trying to parse an " ö "?
This issue can occur from bad formatting from the sender. You are telling the API that the request is sent with UTF-8 encoding but it's in a different type.
Try setting the encoding to UTF-16 and see if that gets it to work.
Hope it helps!
Paulo Rosário
Hello Paulo,
Thanks for the quick reply.
"Try setting the encoding to UTF-16 and see if that gets it to work. "
Is this something I can set in Outsystems? If yes, where can I do that?Kind regards,
Cees
Hi Cees,
You can use the BinaryDataToText from the BinaryData extension to set the encoding and use it on the OnAfterResponse event of your API and set the CustomizedResponse to the output of BinaryDataToText server action.
Something like this:
Let me know if that helped.
This should work :)
We're exposing an api.
I've put your example in the onresponse action.Filled the CustomizedResponse.ResponseText with BinaryDataToText.Text.But I still get the error.
I understood that the error was when consuming a REST API.
Can you enable full logging of that REST API on the service center and check if there's something strange with the JSON request you receive from the external system?
it seems the error is when parsing the Id on the JSON request. Maybe the JSON format is different from what you are expecting or maybe the Position Id data type of the request doesn't match what you are expecting. Just guessing.
It would be easier if I could see the code.
Sorry that I wasn't clear enough in my question.I've already enable the logging and attached the file in my reply.
Strange thing is that when I get the JSON from the logging, and send it with postman, the api works fine.
When I debug the API I only see the OnAuthentication and then the error immediatly occurs.
Your uploaded file doesn't help much :/
The only thing I can guess is that the external system is using a different encoding type on the request than the platform can decode or some compression algorithm like gzip.
Just try to use the BinaryDataToText on the OnRequest Event of your exposed API to "utf-8" or "ISO-8591-1" and check if the JSON doesn't have strange characters (like "?"). If the request is being gzip-compressed, you can try to use this forge component to decompress it:https://www.outsystems.com/forge/component-overview/8684/gzip-compress-decompress
Hope this can help you!