Array of strings which should be numbers?

Why is my array of numbers converted to strings:

Post Content:
Hi there! :wave:

I’m encountering an issue where my array of numbers is being converted to strings in my workflow. Here’s the context:

Result from the workflow:

[
    {
        "deletePages": [
            "0"
        ]
    }
]

Expected Behavior:
The deletePages array should remain as numbers, not strings.

Communication Setup:

{
  "url": "/edit",
  "method": "POST",
  "body": {
    "deletePages": "{{parameters.deletePages}}"
  }
}

Mappable Parameters in the Make App:

{
  "name": "deletePages",
  "type": "array",
  "label": "Delete Pages",
  "required": false,
  "default": [1]
}

I suspect the issue is related to how arrays are handled in Make.com. Is there a way to ensure the deletePages array stays as numbers instead of being converted to strings? Any advice or solutions would be greatly appreciated!

Thanks in advance! :blush:

Result from the workflow:

[
{
“deletePages”: [
“0”
]
}
]

Communication:

{
“url”: “/edit”,
“method”: “POST”,
“body”: {
“deletePages”: “{{parameters.deletePages}}”
}
}

Mappable Parameters in the Make App:

{
“name”: “deletePages”,
“type”: “array”,
“label”: “Delete Pages”,
“required”: false,
“default”: [1]
}

Hi @Endre_F_M,

That is because the items of a primitive array default to be text if you don’t specify otherwise: “When no spec is provided, the array will behave as a primitive array of strings. However, the preferred approach is setting the spec to {"type": "text"} .” (Make.com - Custom App Documentation)

You can use the spec directive to control the type of items in the array.

Cheers,
Henk

1 Like

@Henk-Operative Thank you very much, that one slipped for my when reading through!

It happens to the best of us! :smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.