RocketChat / Rocket.Chat

The communications platform that puts data protection first.
https://rocket.chat/
Other
40.27k stars 10.44k forks source link

[WEBHOOK] Half of payload is missing in request content #10808

Closed kaiiiiiiiii closed 5 years ago

kaiiiiiiiii commented 6 years ago

Description:

I've written a webhook script for PipeDrive which converts the requests payload (json) into a valid rocket.chat message.

The problem I'm running into is the following: As soon as there's an array in the json payload, the payload is missing half of it's content (cut of after the array).

Server Setup Information:

Steps to Reproduce:

  1. Paste Payload 1 into a file and call it whatever.json
  2. Create a new webhook and use the pipedrive script as a custom script
  3. Use CURL to send Payload 1 to the created webhook
  4. Repeat step 1 and 3 with Payload 2 (works, without any arrays in it)

Expected behavior:

Payload (JSON) should be 1 to 1 in the requests content.

Actual behavior:

Payload is cutted after the first array.

Console.log: {"{\r\n\t\"v\": 1,\r\n\t\"meta\": {\r\n\t \"v\": 1,\r\n\t \"action\": \"updated\",\r\n\t \"object\": \"person\",\r\n\t \"id\": 9,\r\n\t \"company_id\": 9,\r\n\t \"user_id\": 9,\r\n\t \"host\": \"company.pipedrive.com\",\r\n\t \"timestamp\": 1525983674,\r\n\t \"timestamp_micro\": 1525983674999300,\r\n\t \"permitted_user_ids\": ":{"\r\n\t\t4754231\r\n\t ":{"\r\n\t\t{\r\n\t\t \"label\": \"work\",\r\n\t\t \"value\": \"666\",\r\n\t\t \"primary\": true\r\n\t\t}\r\n\t ":{"\r\n\t\t{\r\n\t\t \"label\": \"work\",\r\n\t\t \"value\": \"kaismail\",\r\n\t\t \"primary\": true\r\n\t\t}\r\n\t ":{"\r\n\t\t{\r\n\t\t \"label\": \"work\",\r\n\t\t \"value\": \"666\",\r\n\t\t \"primary\": true\r\n\t\t}\r\n\t ":{"\r\n\t\t{\r\n\t\t \"label\": \"work\",\r\n\t\t \"value\": \"kaismail\",\r\n\t\t \"primary\": true\r\n\t\t}\r\n\t ":""}}}}}}

Relevant logs:

Payload 1: https://gist.github.com/kaiiiiiiiii/c3b65ae5ab3363ad803e6c54fddf7f91

Payload 2 (works, without any arrays in it): https://gist.github.com/kaiiiiiiiii/a73c49236da2c0b73ad0b76a646c3af9

PipeDrive Script (I removed most of the logic for this test): https://gist.github.com/kaiiiiiiiii/d4ea07684d8e2445bf49c7090b95cce9

CURL Command: curl -X POST -H 'Content-Type:application/json' --data-binary "@PATH_TO_FILE.json" https://url/hooks/...

geekgonecrazy commented 5 years ago

Still an issue?

kaiiiiiiiii commented 5 years ago

I’ll get back to you tomorrow 👍 Wasn’t a prio 1 issue for me, so I need to check first.

kaiiiiiiiii commented 5 years ago

Seems to work now. Gonna close this issue 👍