# Use {{payload}} to play URL by media\_player

**URL:** <https://discourse.nodered.org/t/use-payload-to-play-url-by-media-player/49634>\
**Category:** General\
**Created:** [11 August 2021 21:34 UTC](https://discourse.nodered.org/t/use-payload-to-play-url-by-media-player/49634 "2021-08-11T21:34:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![krammie](https://avatars.discourse-cdn.com/v4/letter/k/a87d85/32.png) [@krammie](https://discourse.nodered.org/u/krammie)\
**Post date:** [11 August 2021 21:34 UTC](https://discourse.nodered.org/t/use-payload-to-play-url-by-media-player/49634/1 "2021-08-11T21:34:18Z")

</div>

I'm trying to send a payload that consists of an URL to call a service and start this radio stream.  
This is what I've entered in the 'Data' property field:

```auto
{
    "media_content_id": "{{payload}}",
    "media_content_type": "audio/mp3"
}

```

I don't see any error, but the actual URL is not played/streamed to the media device. However, when I use the exact same flow, but enter the URL directly in the 'Data' property (see below), the URL is played and the flow works perfectly.

```auto
{
    "media_content_id": "https://icecast.omroep.nl/3fm-bb-mp3",
    "media_content_type": "audio/mp3"
}

```

Does anyone know how to use payload data to start playing a stream?

---

<div class="post-metadata">

**Author:** ![Gunner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gunner/32/43582_2.png) [@Gunner](https://discourse.nodered.org/u/Gunner)\
**Post date:** [11 August 2021 21:45 UTC](https://discourse.nodered.org/t/use-payload-to-play-url-by-media-player/49634/2 "2021-08-11T21:45:01Z")

</div>

Try {{msg.payload}}

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [11 August 2021 21:49 UTC](https://discourse.nodered.org/t/use-payload-to-play-url-by-media-player/49634/3 "2021-08-11T21:49:44Z")

</div>

Or if the type input field has JSONata (J:) then you can do

```auto
{
    "media_content_id": $$.payload,
    "media_content_type": "audio/mp3"
}

```

[edit] I am guessing this is a homeassitant node, from their docs-

> By default, Mustache will replace certain characters with their HTML escape codes. To stop this happening, you can use triple braces: `{{{payload}}}`

---

<div class="post-metadata">

**Author:** ![krammie](https://avatars.discourse-cdn.com/v4/letter/k/a87d85/32.png) [@krammie](https://discourse.nodered.org/u/krammie)\
**Post date:** [11 August 2021 22:01 UTC](https://discourse.nodered.org/t/use-payload-to-play-url-by-media-player/49634/4 "2021-08-11T22:01:54Z")

</div>

> [@E1cid](#):
>
> `$.payload`

Thanks for your support, but this doesn't work unfortunately. The following error is than showed in debug: Call-service error. string index out of range.

---

<div class="post-metadata">

**Author:** ![krammie](https://avatars.discourse-cdn.com/v4/letter/k/a87d85/32.png) [@krammie](https://discourse.nodered.org/u/krammie)\
**Post date:** [11 August 2021 22:06 UTC](https://discourse.nodered.org/t/use-payload-to-play-url-by-media-player/49634/6 "2021-08-11T22:06:39Z")

</div>

It's indeed a Home Assistant node I'm using. The triple braces solved the issue.  
Thank you for your help!

---

<div class="post-metadata">

**Author:** ![krammie](https://avatars.discourse-cdn.com/v4/letter/k/a87d85/32.png) [@krammie](https://discourse.nodered.org/u/krammie)\
**Post date:** [11 August 2021 22:18 UTC](https://discourse.nodered.org/t/use-payload-to-play-url-by-media-player/49634/7 "2021-08-11T22:18:18Z")

</div>

@alborg; I've seen your post about the same issue. The solution to the issue is described in this topic.

---

<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:** [25 August 2021 22:19 UTC](https://discourse.nodered.org/t/use-payload-to-play-url-by-media-player/49634/8 "2021-08-25T22:19:12Z")

</div>

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