Why does my custom app module body send the object as a JSON array?

Hello All,

I’m trying to figure out why my custom app module is sending the body or the request as a json array. Here is what is specified in the Communication of the module:

{
“url”: “/v2/integration/assign”,
“method”: “POST”,
“headers”: {
“Authorization”: “Bearer {{connection.token}}”
},
“qs”: {},
“body”: {
“userId”: “{{parameters.userId}}”,
“projectId”: “{{parameters.projectId}}”,
“addToAllSteps”: “{{parameters.addToAllSteps}}”,
“addToCustomerFacing”: “{{parameters.addToCustomerFacing}}”,
“addToStepsWithTags”: “{{parameters.addToStepsWithTags}}”,
“selectedTagIds”: [“{{parameters.selectedTagIds}}”]
},
“response”: {
“output”: “{{body}}”
},
“log”: {
“sanitize”: [“request.headers.authorization”]
}
}

When testing this module, I noticed that the input bundle is wrapping the JSON object in an array like this:

[
{
“userId”: 711,
“projectId”: 80,
“addToAllSteps”: false,
“selectedTagIds”: [
3
],
“addToStepsWithTags”: true,
“addToCustomerFacing”: false
}
]

The endpoint is not expecting an array but a single object. Like this:

{
“userId”: 711,
“projectId”: 80,
“addToAllSteps”: false,
“selectedTagIds”: [
3
],
“addToStepsWithTags”: true,
“addToCustomerFacing”: false
}

Why is the content getting created like it is and what do I need to change so that the array is not created?

Thanks.

Hello,

Are you using the Chrome DevTool Extension? This might help you see exactly what Make sends in the request body.

What you could also try is to adjust the body to send all parameters directly, as follows:

"body": "{{parameters}}"

2 Likes

Thanks for the suggestion, @Thomas_Gaillard. That got me unblocked. Unfortunately it doesn’t explain the behavior–why Make is formatting the body as a JSON array when explicitly creating the object fields.