Hi everyone,
I’m currently facing an issue with constructing my body request for a module of a Custom App I am developping. The challenge arises because I need to handle optional parameters and conditionally exclude certain objects from the final JSON payload.
I have two parameters, parameters.images
and parameters.event_description
, which are optional. Depending on whether these parameters are filled or not, I need to:
- Exclude the entire parent object if the parameters are null.
- If both parameters are null, exclude the entire
content
object.
Here’s the current JSON body request I’m working with:
"content": {
"en": [
{
"type": "item",
"attributes": {
"assets": "{{parameters.images}}"
},
"relationships": {
"item_type": {
"data": {
"id": "1102482",
"type": "item_type"
}
}
}
},
{
"type": "item",
"attributes": {
"content": {
"schema": "dast",
"document": {
"children": [
{
"children": [
{
"type": "span",
"value": "{{parameters.event_description}}"
}
],
"type": "paragraph"
}
],
"type": "root"
}
},
"is_wide": null
}
]
}
Make.com currently treats null values by “hiding” only the actual object, but I need the entire parent object to be excluded if both parameters.images
and parameters.event_description
are null otherwise I receive an error. Here is the body request sent by Make when both parameters are null:
"content": {
"en": [
{
"type": "item",
"attributes": {},
"relationships": {
"item_type": {
"data": {
"id": "1102482",
"type": "item_type"
}
}
}
},
{
"type": "item",
"attributes": {
"content": {
"schema": "dast",
"document": {
"type": "root",
"children": [
{
"type": "paragraph"
}
]
}
},
"is_wide": null
},
"relationships": {
"item_type": {
"data": {
"id": "1099719",
"type": "item_type"
}
}
}
}
]
Notice that only “assets” and “children” were removed from the payload.
Can anyone provide guidance or a snippet on how to construct this JSON object correctly in Make.com? Specifically, how can I ensure the entire content
object is excluded if both parameters.images
and parameters.event_description
are null? Any help or direction to relevant documentation would be greatly appreciated!
Thank you in advance!