How to fix Body is not a valid JSON. Unexpected token '', "{"errors""... is not valid JSON

Hello, I am kinda new to the make community, and had an issue where whenever I receive an answer from an API (in a custom app in a custom module), it comes with this whitespace character as the first character, and make doesnt seem to like that and doesnt parse the JSON from it (throws the error in the title). Is there a way to tell make to either ingore it or something like that? Any answer will be helpful

Code and the error for reference:


Welcome to the Make community!

Doesn’t seem to be an issue with your module. You should post examples of the response payload instead.

Try using the built-in function trim

{{ trim(text) }}

For more information, the function’s documentation can be found in the Help Centre. You should also complete the tutorials in the Make Academy.

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.

I will definitely try the tutorials, thanks! But for now this is what the response looks like:


(The screenshot is from reqbin.com, since I dont know how to get to it in make, apart from the DevTool, but you cant really see the character there). Also here is the character copied: “”.

And referring to the trim function, would this be would that would look like?
“response”: {
“output”: “trim({{response.body}})”
}

anyone, please? I found out that the character I am talking about is known as BOM (Byte order mark), but I still dont know how to get rid of it

According to

it’s not valid JSON. You should contact the external service to ask them to fix the encoding instead so that the BOM isn’t added incorrectly.

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.