REST Destination default value

20 views
Skip to first unread message

mgmort mgmort

unread,
Dec 14, 2025, 9:49:03 AM (10 days ago) Dec 14
to COZYROC
I have a custom REST connection that normally does a 'Create' post, with a single parameter: {{={ data: batch } }}, where 'batch' contains all the rows as json.

The user of the destination has requested that when I have no rows to post, I still send a payload like { "data": [ {} ] }, but it seems that when there are no rows, the rest destination only creates a post with a null payload. I have tried adding the string as 'default value' to my payload parameter, but this doesn't seem to have any effect. How can I send the default text when there are no rows passing through the destination?

Ivan Peev

unread,
Dec 15, 2025, 7:00:51 AM (9 days ago) Dec 15
to COZYROC
Try the following expression: {{={ data: batch || [{}] } }}

mgmort mgmort

unread,
Dec 16, 2025, 8:53:49 AM (8 days ago) Dec 16
to COZYROC
Ivan, this doesn't work, it seems that if there are no rows, the post is never made regardless of the expression?

In the Endpoint Test dialog, the expression works if the input record is {}, but not if it is empty, and apparently that is what happens when there are no rows.
Here is what I see in the Connection Manager Log:
16/12/2025 15:39:06| Evaluate template: {{= { data: batch || [ {} ] }  }}
--- Parameter 'resource': {
  "name": "YediotTasksProd"
}

16/12/2025 15:39:06| Template evaluation result: {
  "data": []
}
16/12/2025 15:39:06| Evaluate template: {{=response.o_result}}
--- Parameter 'resource': {
  "name": "YediotTasksProd"
}

16/12/2025 15:39:06| Template evaluation result:
16/12/2025 15:39:06| Evaluate template: {{=response.o_result}}
--- Parameter 'resource': {
  "name": "YediotTasksProd"
}

I also tried checking the batch.length, which shows the full blank set in the evaluation result, but still never post to the api:
16/12/2025 15:48:21| Evaluate template: {{= { data: batch.length>0 ? batch : [ {} ] } }}
--- Parameter 'resource': {
  "name": "YediotTasksProd"
}

16/12/2025 15:48:21| Template evaluation result: {
  "data": [
    {}
  ]
}
16/12/2025 15:48:21| Evaluate template: {{=response.o_result}}
--- Parameter 'resource': {
  "name": "YediotTasksProd"
}

16/12/2025 15:48:21| Template evaluation result:
16/12/2025 15:48:21| Evaluate template: {{=response.o_result}}
--- Parameter 'resource': {
  "name": "YediotTasksProd"
}

I considered modifying my source SQL to add a 'null' row when there are no records, that I could capture using item.id = null in my template, but I couldn't find a syntax that would make that work either (item. seems to always be undefined).

Any other suggestions?

Ivan Peev

unread,
Dec 17, 2025, 7:02:09 AM (7 days ago) Dec 17
to COZYROC
You can use the REST Web Services Request Task reusable script here to send the empty request.

mgmort mgmort

unread,
Dec 17, 2025, 8:50:08 AM (7 days ago) Dec 17
to COZYROC
Perfect, thanks.
Reply all
Reply to author
Forward
0 new messages