最近搜索


没有最近搜索

Complex JSON in webhook body

已回答


已于 2022年1月27日 发布

As part of my webhook event whenever a ticket is created/updated, I'm trying to send a JSON response that mirrors what I would receive when I do a GET request to the `api/v2/tickets/` endpoint.

Is it possible to do something like this:

{ "ticket": {{ticket}} }

Or if I had to recreate the whole response, it'd be nice if the following:

{ "ticket": { 
"comments": "{{ticket.comments}}"
}
}

would give me a proper list of ticket comments as opposed to a string List. It's making processing on my end extremely difficult and I'm wondering if there's any way to fix this

 




1

2

2 条评论

Yes. It sounds like what you want to do is format the comments better, individually, which you can do by iterating over each one with a for loop. I can't really test it (so very easily could be syntax typos) but it should be something like:

{"ticket": {
{% for comment in ticket.comments %} "Comment": "{{comment.value}}"
{% endfor %}
}
}

I actually just found an article too that goes more into it, and seems like you've got it already but for anyone else looking to do something similar, here's the placeholders reference

1


Thanks Dan! I tried to use the Liquid markup earlier but probably messed up the syntax so I just assumed it didn't work. Thanks for the help

0


请先登录再写评论。

找不到所需的内容?

新建帖子