How to send JSON body in rule?


I have created a webhook connector which uses servicenow api to send, then I have created a rule and used that webhook connector so whenever that rule trigger I need to send that alert data in body as a JSON as servicenow api expect data in json format.

{"caller_id": "xyz", "u_ticket_classification": "ticket", "impact": "3", "urgency": "3", "short_description": "{{}}", "description": "{{rule.description}}", "opened_by": "xyz", "contact_type": "email"}

but this is not working not getting data, please let me know the correct way.

Welcome @navin547. Thanks for reaching out.

Do you have a code sample you are using? Are you encountering any errors? You may want to double-check that your Content-Type header is set to application/json.

Hey @jessgarson thanks, I am able to send the body in JSON format by using {{#ParseHjson}}, but I am not able to get the document details ({{context.hits.0._source.message}}) could you please help me.

I am using below code.

{"caller_id": "xyz", "u_ticket_classification": "ticket", "impact": "3", "urgency": "3", "short_description": "{{}}", "description": "{{context.hits.0._source.message}}", "opened_by": "xyz", "contact_type": "email"}
1 Like

Thanks for following up, @navin547.

It seems you can use the Mustache template array syntax to iterate the hits. This similar forum post suggests that you can add {{.}} within that message to get a listing of all the available variables.

Hope this helps!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.