Webhook with full doc as json

I’m working with ERPNext on frappe.cloud

I have a webhook for Task (on_change).
It’s working for individual, named fields:

image

However, I want the whole doc object in the body, but this is not working

I have tried:

{{doc}}
"{{doc}}"
{
  "doc": "{{doc}}"
}

… but I can’t get the whole object out.

I have also tried
{{json.dumps(doc.__dict__)}}
and
"{{json.dumps(doc.__dict__)}}"

Sorry to bump this up.

I came across this problem as well but I finally found the solution!

All you have to do is add |tojson|safe to the variable {{doc}} like this {{doc|tojson|safe}}

The reason is because the WebHook controller calls the “frappe.render_template” function which returns a doctype object instead of JSON

Cheers,

The string filter worked for me. The JSON response body is:

{
"doc": "{{ doc | string }}"    
}
1 Like

When I creating Webhooks? I can’t edit json objects here. i don’t know why?