Formatting of " " when using Liquid markup on Api request
Posted Jan 25, 2024
Having an issue when trying to format Liquid on a request.
When creating or updating a ticket via Api request i am using this format:
{
"ticket":{
"requester_id" : "{{ticket.requester.id}}",
"collaborator_ids": ["{% if ticket.cc_names != empty %}{% capture ccedusers %}{% for cc in ticket.ccs %}{% unless forloop.last %}{{ cc.id | append: ', ' }}{% else %}{{ cc.id }}{% endunless %}{% endfor %}{% endcapture %}{{ ccedusers | strip_newlines }}{% else %}{% endif %}"]
}
When recovering requester_id the " " would not affect the syntax but for collaborator_ids need to be inside [ ]. When using liquid, the values are recovered properly but they require to be inside " " for the request to be correct.
Depending on where " " are placed the request would be successful but the " " will always interfere on the format and not recover the cc values.
they can be recovered as:
"collaborator_ids": "[12345678910, 12345678911]"
or as:
"collaborator_ids": ["12345678910, 12345678911"]
but none seem to work to add the users... ideally, the first sample would ignore the " " just as requester_id does, but cannot make it work.
Any suggestion would be greatly appreciated.
Thank you!
0
1 comment
Sign in to leave a comment.