Getting data from webhook

Can anybody tell me whats wrong in this,
{
“reference_name”: “{{ doc.reference_name }}”,
“comment_email”: “{{ doc.comment_email }}”,
“content”: “{{ doc.content }}”
}
I am using webhook to send data from erpnext to nodejs app, doctype is comment when new comment add it triger, now if, I select
{
“reference_name”: “{{ doc.reference_name }}”,
“comment_email”: “{{ doc.comment_email }}”
} fields it work but when i add content it give me error,
Traceback (most recent call last):
File “apps/frappe/frappe/integrations/doctype/webhook/webhook.py”, line 175, in enqueue_webhook
data = get_webhook_data(doc, webhook)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/integrations/doctype/webhook/webhook.py”, line 262, in get_webhook_data
data = json.loads(data)
^^^^^^^^^^^^^^^^
File “/usr/lib/python3.11/json/init.py”, line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/lib/python3.11/json/decoder.py”, line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/lib/python3.11/json/decoder.py”, line 353, in raw_decode
obj, end = self.scan_once(s, idx)
^^^^^^^^^^^^^^^^^^^^^^
json.decoder.JSONDecodeError: Expecting ‘,’ delimiter: line 2 column 459 (char 460)

  1. when I used URL-Encoded data type it works but I am getting data in form of
    {
    ‘{“comment_email”: “Administrator”, “content”: "<div class’: ‘\“ql-editor read-mode\”>

    hiiii

    ", “reference_name”: “GIF_001”}’
    }
    and I am not able to access it, it is in object of object but if i check typeof req.body it show object, please help me if anyone know how to solve it

The problem relays on the content field. the data inside the field contains html tags and new line characters not sure if erpnext is creating the JSON file properly.
Here is the same behavior Webhook for Task with "description" fails · Issue #28379 · frappe/erpnext · GitHub
Do this add "| striptags |e " to your field and it should work

“content”: “{{ doc.content | striptags |e }}”

1 Like