# Problems converting webhook to JSON object

**URL:** <https://discourse.nodered.org/t/problems-converting-webhook-to-json-object/55532>\
**Category:** General\
**Created:** [21 December 2021 16:27 UTC](https://discourse.nodered.org/t/problems-converting-webhook-to-json-object/55532 "2021-12-21T16:27:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![HaltHammerzeit](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/halthammerzeit/32/52699_2.png) [@HaltHammerzeit](https://discourse.nodered.org/u/HaltHammerzeit)\
**Post date:** [21 December 2021 16:27 UTC](https://discourse.nodered.org/t/problems-converting-webhook-to-json-object/55532/1 "2021-12-21T16:27:58Z")

</div>

Hello all.

I suppose I should mention that I am quite new to Node-RED. 🙂

I have a webhook from Plex being sent to Node-RED via [http://webhookrelay.com](http://webhookrelay.com). I have the connector node working, and RED is receiving messages, but I am having trouble with the message that is being received from webhook-relay. The message comes in as a JSON object, which I believe is a wrapper from webhook-relay.

Debug Output

```auto
21/12/2021, 16:45:34node: webhook_dbg
plexbucket : msg.payload : Object
object
type: "webhook"
meta: object
id: "##############################"
bucked_id: "##############################"
bucket_name: "plexbucket"
input_id: "##############################"
input_name: "Default public endpoint"
output_name: ""
output_destination: ""
headers: object
Accept: array[1]
0: "*/*"
Accept-Encoding: array[1]
0: "gzip"
Content-Length: array[1]
0: "12062"
Content-Type: array[1]
0: "multipart/form-data; boundary=------------------------c7b26957a9fb7c1b"
User-Agent: array[1]
0: "##############################"
query: ""
body: "--------------------------c7b26957a9fb7c1b↵Content-Disposition: form-data; name="payload"↵Content-Type: application/json↵↵{"event":"media.scrobble","user":true,"owner":true,"Account":{"id":1,"thumb":"##############################","title":"######"},"Server":{"title":"################","uuid":"############################"},"Player":{"local":true,"publicAddress":"###.###.###.###","title":"Microsoft Edge","uuid":"##############################"},"Metadata":{"librarySectionType":"show","ratingKey":"16633","key":"/library/metadata/16633","parentRatingKey":"16632","grandparentRatingKey":"16631","guid":"plex://episode/616457d0dcafa2bcb75c96db","parentGuid":"plex://season/61651249024c21eb63bf0a9e","grandparentGuid":"plex://show/616457cedcafa2bcb75c96b1","type":"episode","title":"Episode 1","grandparentKey":"/library/metadata/16631","parentKey":"/library/metadata/16632","librarySectionTitle":"TV","librarySectionID":2,"librarySectionKey":"/library/sections/2","g..."
method: "POST"

```

However, I am having trouble parsing out the BODY part of the message in to its own object for use in other thing like functions and switches. The content of body should already contain JSON data, which I hope to use in a switch...

`[{"id":"db306fc76c716133","type":"switch","z":"f6f2187d.f17ca8","name":"Media Function","property":"payload.body.event","propertyType":"msg","rules":[{"t":"eq","v":"media.pause","vt":"str"},{"t":"eq","v":"media.play","vt":"str"},{"t":"eq","v":"media.rate","vt":"str"},{"t":"eq","v":"media.resume","vt":"str"},{"t":"eq","v":"media.scrobble","vt":"str"},{"t":"eq","v":"media.stop","vt":"str"}],"checkall":"true","repair":false,"outputs":6,"x":480,"y":260,"wires":[["acd8d7b6e0288518"],["acd8d7b6e0288518"],["acd8d7b6e0288518"],["acd8d7b6e0288518"],["c68cd89e5eacced5","acd8d7b6e0288518"],["acd8d7b6e0288518"]]}]`

But the switch does not appear to respond to msg.payload.body.

I've tried running msg.payload.body through a JSON node...

[{"id":"96f5b34c29df3823","type":"json","z":"f6f2187d.f17ca8","name":"","property":"payload.body","action":"","pretty":true,"x":680,"y":780,"wires":[["66448228366602c1"]]}]

But all I get out of it is a string, containing the JSON Data, and I'm at a loss on how to get this as a usable object.

(Also, as an aside. I've also tried configuring direct input from Plex Webhook using a HTTP-IN node, but all I get I gibberish (a buffer msg.payload with hex values 😕 )

Any pointers or advice to remedy this would be greatly appreciated 🙂

H

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [21 December 2021 17:41 UTC](https://discourse.nodered.org/t/problems-converting-webhook-to-json-object/55532/2 "2021-12-21T17:41:19Z")

</div>

If you just want to work with the content of the `msg.payload.body` \< that is how you would use it in a function or switch node.

A switch node is used for routing messages to different nodes, it does not modify the message contents.

Make sure to [go through the documentation](https://nodered.org/docs/user-guide/messages) that covers all these subjects.

What are you trying to accomplish ?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [19 February 2022 17:41 UTC](https://discourse.nodered.org/t/problems-converting-webhook-to-json-object/55532/3 "2022-02-19T17:41:53Z")

</div>

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