Pesquisas recentes


Sem pesquisas recentes

Complex JSON in webhook body

Respondido


Publicado 27 de jan. de 2022

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 comentários

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


Por favor, entrar para comentar.

Não encontrou o que estava procurando?

Nova publicação