# RGB Array in call service

**URL:** https://discourse.nodered.org/t/rgb-array-in-call-service/34523
**Category:** General
**Created:** [19 October 2020 20:46 UTC](https://discourse.nodered.org/t/rgb-array-in-call-service/34523 "2020-10-19T20:46:29Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Buva79](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/buva79/32/58661_2.png) [@Buva79](https://discourse.nodered.org/u/Buva79)
#### Post date: [19 October 2020 20:46 UTC](https://discourse.nodered.org/t/rgb-array-in-call-service/34523/1 "2020-10-19T20:46:29Z")

</div>

Hi,

I'm trying to send an array with RGB values to call service -\> Data.  
I use in Data: {"rgb\_color":{{payload}}}.  
I get: "Call-service API error. Error Message: extra keys not allowed @ data['0']"  
If I copy the values of that array straight into the data field it works...  
Would somebody know what I'm doing wrong and how to fix it?

Thanks,  
Buva

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [19 October 2020 21:49 UTC](https://discourse.nodered.org/t/rgb-array-in-call-service/34523/2 "2020-10-19T21:49:27Z")

</div>

Hi.

You haven't gave a lot to go on.

What nodes are you using?  
What is in payload?  
What should you be sending (provide a sample data).

---

<div class="post-metadata">

### Author: ![Buva79](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/buva79/32/58661_2.png) [@Buva79](https://discourse.nodered.org/u/Buva79)
#### Post date: [20 October 2020 18:40 UTC](https://discourse.nodered.org/t/rgb-array-in-call-service/34523/3 "2020-10-20T18:40:44Z")

</div>

Hi,

Here is the code:

```auto
[{"id":"2a4d2487.8ff5fc","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"2ce4f9d.110a806","type":"ui_colour_picker","z":"2a4d2487.8ff5fc","name":"","label":"RGB FL1","group":"9bc5e3b7.87534","format":"rgb","outformat":"object","showSwatch":true,"showPicker":true,"showValue":true,"showHue":false,"showAlpha":false,"showLightness":true,"square":"false","dynOutput":"false","order":4,"width":5,"height":4,"passthru":true,"topic":"","x":160,"y":60,"wires":[["9a7c363e.a2d378"]]},{"id":"87b9b146.0f349","type":"function","z":"2a4d2487.8ff5fc","name":"","func":"var text = msg.payload\nvar len = text.length;\nvar cut = len-3\nvar nw = msg.payload.substring(0,cut)\nmsg.payload=nw\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":400,"y":160,"wires":[["604101cb.0d3a1","c7389bcc.e8a318"]]},{"id":"604101cb.0d3a1","type":"function","z":"2a4d2487.8ff5fc","name":"","func":"var ar =msg.payload.split(',').map(ar => parseInt(ar,10));\nmsg.payload=ar\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":400,"y":220,"wires":[["6bcc7318.fd946c","22de8182.428a8e"]]},{"id":"6bcc7318.fd946c","type":"api-call-service","z":"2a4d2487.8ff5fc","name":"LIGHT BED","server":"5215b5bc.f7c15c","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.bed","data":"{\"rgb_color\":{{payload}}}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":410,"y":300,"wires":[["89a03704.d0dfd8"]]},{"id":"89a03704.d0dfd8","type":"debug","z":"2a4d2487.8ff5fc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":610,"y":300,"wires":[]},{"id":"22de8182.428a8e","type":"debug","z":"2a4d2487.8ff5fc","name":"F2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":590,"y":220,"wires":[]},{"id":"c7389bcc.e8a318","type":"debug","z":"2a4d2487.8ff5fc","name":"F1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":590,"y":160,"wires":[]},{"id":"fbc58201.db4c8","type":"debug","z":"2a4d2487.8ff5fc","name":"RGB out","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":600,"y":100,"wires":[]},{"id":"9a7c363e.a2d378","type":"csv","z":"2a4d2487.8ff5fc","name":"","sep":",","hdrin":"","hdrout":"","multi":"one","ret":"\\n","temp":"r,g,b,a","skip":"0","strings":true,"include_empty_strings":false,"include_null_values":false,"x":310,"y":100,"wires":[["87b9b146.0f349","fbc58201.db4c8"]]},{"id":"9bc5e3b7.87534","type":"ui_group","z":"","name":"HOME","tab":"57c688f9.3fc498","order":1,"disp":true,"width":"6","collapse":false},{"id":"5215b5bc.f7c15c","type":"server","z":"","name":"Home Assistant","addon":true},{"id":"57c688f9.3fc498","type":"ui_tab","z":"","name":"RED Home","icon":"RED dashboard","disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [20 October 2020 19:29 UTC](https://discourse.nodered.org/t/rgb-array-in-call-service/34523/4 "2020-10-20T19:29:15Z")

</div>

There is no way I am going to (and likely others) import your code, figure out what nodes you have installed & guess your payload & then attempt to figure out the expected format.

If you answer the questions I posted, I will attempt to help.

---

<div class="post-metadata">

### Author: ![Buva79](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/buva79/32/58661_2.png) [@Buva79](https://discourse.nodered.org/u/Buva79)
#### Post date: [24 October 2020 17:58 UTC](https://discourse.nodered.org/t/rgb-array-in-call-service/34523/5 "2020-10-24T17:58:52Z")

</div>

OK Steve,

This is my first question in any forum whatsoever so bear with me please.

I'm using the Colour picker and I transform the value into an array eg. [62, 156, 193]  
When I try to put this in the data field of a call service with {"rgb\_color":{{payload}}}, I get "Call-service API error. Error Message: None for dictionary value @ data['rgb\_color']" in the debugger.  
I probably just don't know how to put the payload into the Data field of the call service node...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/9/c9d6847890a0b8ebb904cc3d812fff9d756daddb.png)

BR,  
Burt.

---

<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: [24 October 2020 18:11 UTC](https://discourse.nodered.org/t/rgb-array-in-call-service/34523/6 "2020-10-24T18:11:48Z")

</div>

Using the mustache temple does not like arrays and objects, try converting it to a json string "[56,67,147]". Or use the string value from your second debug, then in the api call use `{"rgb_color":[{{payload}}]}`

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [24 October 2020 18:21 UTC](https://discourse.nodered.org/t/rgb-array-in-call-service/34523/7 "2020-10-24T18:21:56Z")

</div>

On that data input (the one highlighted, if you click the drop-down on the left of it, what options are available? Is there a `msg` option?

---

<div class="post-metadata">

### Author: ![Buva79](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/buva79/32/58661_2.png) [@Buva79](https://discourse.nodered.org/u/Buva79)
#### Post date: [24 October 2020 20:59 UTC](https://discourse.nodered.org/t/rgb-array-in-call-service/34523/8 "2020-10-24T20:59:39Z")

</div>

That did the job! Thanks!

---

<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: [7 November 2020 20:59 UTC](https://discourse.nodered.org/t/rgb-array-in-call-service/34523/9 "2020-11-07T20:59:47Z")

</div>

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