Invalid JSON for number type

We have a custom action that sends some data to an external API, one of which is a number.

However, it seems that it’s possible for Adalo to send an incorrect value (blank) which is technically invalid json and therefore cannot be parsed at the other end.

Here is a summarised view of the the data that is sent…

{
“postData”: {
“contents”: “{"current_task_sequence": ,"user_id": 115}”,
“name”: “postData”,
“type”: “application/json”
},
“contentLength”: 148
}

Unfortunately for us this seems to happen intermittently and our best guess is that it originates from a Custom Formula which is proving difficult to diagnose. However, the fact that it’s even possible to send invalid JSON would seem to be an Adalo bug as I would expect it to at least send the default value or 0 and it should never send blank for a number data type.

Hi Ross,

It is possible it’s the hidden character formatting. If you look closely at what you pasted above, you’ll see two different types of quote marks.
image

You have “ as well as ".

This might seem strange, but some APIs won’t accept these stylized apostrophes. They are probably in your custom action due to copy and pasting. You can delete and retype them and they will be the correct (straight vertical) format.

I’d check this first, I’ve encountered issues with it before.

Hi!

Thanks for the reply. The outer speech marks come from pushing this JSON log to Slack and then me copying and pasting it in so the only thing received by the API is the curly braces and inward. Therefore I don’t think this is the issue.

The issue I’m identifying is that
“current_task_sequence”: ,
is not valid JSON.

It should either be:
“current_task_sequence”: "" ← hoping Adalo wouldn’t do a string as it knows its a number
“current_task_sequence”: 0, ← Not ideal but reasonable
“current_task_sequence”: null, ← Probably the most accurate given a NaN situation

They should be straight, not curly. You sure this is ruled out?

Is the JSON set up in the custom action, or are you trying to send the whole JSON payload into the custom action dynamically?

Hello,

Sorry to clarify, the JSON here is not what we’re putting as the payload, this is the JSON received at the other end so they should be curly as this is the application/json payload.

The value of current_task_sequence is a custom formula (numeric) within a custom action set one property at a time. It’s the result of that custom formula which is somehow creating a blank - the reason for that is still unknown but the only point I was trying to make in this post is that no matter what this custom formula returns, Adalo should not be posting a blank value.

Hey @Ross,

Passing numbers in custom actions could be glitchy sometimes. Few things to check:

  • set the formatting of the number to “none”. When the formatting is set to “default”, Adalo adds commas for thousands which breaks the JSON.
  • sometimes in custom actions you can add some extra math operation like 1-1+… (where … is your formula). This may help to get 0 as a result

You can also check what’s being passed as a custom action payload in browser console - this may give a hint on what’s happening.

Best,
Victor

1 Like

Hey Victor,

One of the variables used was indeed set to “Default” so will give that a try - thank you.

Ross

1 Like