Make an API Call from e.g. Crisp Integration doesn't like spaces in body (json)

Took me a while to debug.

body was

{“state”: “unresolved”}

Make Error was:

Function ‘if’ finished with error! Function ‘parseJSON’ finished with error! Unexpected token ​ in JSON at position 24

Found the solution inderictly via:

The problem is not the last char but actually the space after the colon : you need to make sure to remove ALL SPACES in any json you give in the body (except maybe inside Strings “like here”)

This is (a) not a helpful error message and (b) doesnt make any sense. Why cant the internal parser handle this automatically?

I do consider this a bug, what do you think?

Leo

I’m curious how does your Scenario look, and where are you using an if() function and also getting the ‘parseJSON’ error?

I would think that if you’re submitting JSON text to a Crisp module, or any module, I wouldn’t say any parsing is being done at all and the JSON is simply being passed to the module as-is, to be further processed by that module.

3 Likes

it’s nothing special and the if is inside the Crisp “Make an API call” from standard make.com Integration (see second screenshot)


the problem is the Body at the end. if it includes a space char I get that error

I found another elegant solution for this. using replace to make spaces emptystring:

image

{{replace(“{
““event””: ““session:set_data””,
““data””: {
““trelloCardID””: “”” + 15.id + “”"
},
““timestamp””: " + timestamp + "
}"; space; emptystring)}}

Better readability and works everytime. the newlines do not seem to be problem

2 Likes

Hey there @leotulipan :wave:,

Just thought I might step in and pat you on the back for the great job you did while figuring out this problem. I’m thrilled to see you were able to learn more about the product and come up with a solution! :clap:

Also thank you for coming back and sharing this.
Keep up the amazing work!

1 Like