# Some Advise by using "http request" node

**URL:** <https://discourse.nodered.org/t/some-advise-by-using-http-request-node/42566>\
**Category:** General\
**Created:** [13 March 2021 07:49 UTC](https://discourse.nodered.org/t/some-advise-by-using-http-request-node/42566 "2021-03-13T07:49:41Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![calberts](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/calberts/32/34312_2.png) [@calberts](https://discourse.nodered.org/u/calberts)\
**Post date:** [13 March 2021 07:49 UTC](https://discourse.nodered.org/t/some-advise-by-using-http-request-node/42566/1 "2021-03-13T07:49:41Z")

</div>

ALL

I use the http request node to instruct a system to do something

where single command is used it work fine.  
[http://192.168.1.11:11111/api/v1/telescope/0/unpark](http://192.168.1.11:11111/api/v1/telescope/0/unpark)

But the question is how to deal with the following http string

[http://192.168.1.11:11111/api/v1/telescope/0/slewtocoordinatesasync](http://192.168.1.11:11111/api/v1/telescope/0/slewtocoordinatesasync)" -H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded" -d "RightAscension=0&Declination=90&ClientID=&ClientTransactionID="

the following is not working

```auto
[{"id":"4162b8d3.6fadb8","type":"ui_button","z":"55c1b3dc.91214c","name":"Goto ZeroPosition","group":"8e238b13.7c40b8","order":14,"width":0,"height":0,"passthru":false,"label":"<font size=\"+1\">Goto ZeroPosition</font>","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":190,"y":840,"wires":[["8932f8e.c5c8888"]]},{"id":"8932f8e.c5c8888","type":"http request","z":"55c1b3dc.91214c","name":"","method":"PUT","ret":"txt","paytoqs":"ignore","url":"http://192.168.1.11:11111/api/v1/telescope/0/slewtocoordinates -d \"RightAscension=0&Declination=90\"","tls":"","persist":false,"proxy":"","authType":"","x":390,"y":840,"wires":[[]]},{"id":"8e238b13.7c40b8","type":"ui_group","name":"ALPACA","tab":"dd962aa5.a268f8","order":2,"disp":true,"width":"8","collapse":true},{"id":"dd962aa5.a268f8","type":"ui_tab","name":"OCS","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

```

Hoop some can help or give some advise

Chris

---

<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:** [13 March 2021 08:45 UTC](https://discourse.nodered.org/t/some-advise-by-using-http-request-node/42566/2 "2021-03-13T08:45:30Z")

</div>

> [@calberts](#):
>
> some advise

Look at [this post](https://discourse.nodered.org/t/best-way-to-run-a-curl-command/29594/7) where I demonstrate how to break down a curl to a request.

---

<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:** [13 March 2021 09:58 UTC](https://discourse.nodered.org/t/some-advise-by-using-http-request-node/42566/3 "2021-03-13T09:58:31Z")

</div>

Try

```auto
http://192.168.1.11:11111/api/v1/telescope/0/slewtocoordinatesasync?RightAscension=0&Declination=90&ClientID=&ClientTransactionID=

```

---

<div class="post-metadata">

**Author:** ![calberts](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/calberts/32/34312_2.png) [@calberts](https://discourse.nodered.org/u/calberts)\
**Post date:** [13 March 2021 11:42 UTC](https://discourse.nodered.org/t/some-advise-by-using-http-request-node/42566/4 "2021-03-13T11:42:43Z")

</div>

thanks

this is working via the command line  
curl -X PUT "[http://192.168.1.11:11111/api/v1/telescope/0/slewtocoordinatesasync](http://192.168.1.11:11111/api/v1/telescope/0/slewtocoordinatesasync)" -H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded" -d "RightAscension=0&Declination=90"

`http://192.168.1.11:11111/api/v1/telescope/0/slewtocoordinatesasync?RightAscension=0&Declination=90&ClientID=&ClientTransactionID=`  
unfortunately this is not working

and what is wrong with the payload below

```auto
[{"id":"37d01ae9.869d66","type":"change","z":"55c1b3dc.91214c","name":"","rules":[{"t":"set","p":"headers","pt":"msg","to":"{\"accept\": \"application/json\" }","tot":"json"},{"t":"set","p":"headers","pt":"msg","to":"{\"Content-Type\":\"application/x-www-form-urlencoded\"}","tot":"json"},{"t":"set","p":"payload","pt":"msg","to":"{\"RightAscension=0&Declination=90\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":900,"wires":[[]]}]

```

Chris

---

<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:** [13 March 2021 12:04 UTC](https://discourse.nodered.org/t/some-advise-by-using-http-request-node/42566/5 "2021-03-13T12:04:13Z")

</div>

> [@calberts](#):
>
> unfortunately this is not working

then try adding the data as the body using msg.payload. and setting the headers.

```auto
[{"id":"8cc43cea.d1c7d8","type":"inject","z":"5a245aa1.510164","name":"","props":[{"p":"payload"},{"p":"headers.Content-Type","v":"application/x-www-form-urlencoded","vt":"str"},{"p":"headers.accept","v":"application/json","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"RightAscension=0&Declination=90","payloadType":"str","x":160,"y":3500,"wires":[["c6ad4b46.d17d48"]]},{"id":"c6ad4b46.d17d48","type":"http request","z":"5a245aa1.510164","name":"","method":"PUT","ret":"obj","paytoqs":"ignore","url":"http://192.168.1.11:11111/api/v1/telescope/0/slewtocoordinatesasync","tls":"","persist":false,"proxy":"","authType":"","x":350,"y":3500,"wires":[[]]}]
```

---

<div class="post-metadata">

**Author:** ![calberts](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/calberts/32/34312_2.png) [@calberts](https://discourse.nodered.org/u/calberts)\
**Post date:** [13 March 2021 12:28 UTC](https://discourse.nodered.org/t/some-advise-by-using-http-request-node/42566/6 "2021-03-13T12:28:02Z")

</div>

i got in debug

"Invalid 'to' JSON property"

Chris

---

<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:** [13 March 2021 12:39 UTC](https://discourse.nodered.org/t/some-advise-by-using-http-request-node/42566/7 "2021-03-13T12:39:21Z")

</div>

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

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

Here is a demo using what I think you might ultimately need (variable values for the RightAscension and Declination)...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/d/8d7b080877ce184c464c9a836f8ea250dde857a1.png)

↑ obviously the requests dont work for me.

* * *

the demo flows...

```auto
[{"id":"8301c88b.e286b8","type":"inject","z":"b872cb4b.5a6448","name":"RightAscension 0 Declination 90","props":[{"p":"payload"},{"p":"payload.RightAscension","v":"0","vt":"num"},{"p":"payload.Declination","v":"90","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{}","payloadType":"json","x":870,"y":740,"wires":[["7a0a8426.78786c"]]},{"id":"9f3f7877.59ad98","type":"function","z":"b872cb4b.5a6448","name":"set headers","func":"msg.headers = {\n \"accept\": \"application/json\",\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n}\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1370,"y":760,"wires":[["fa3f2e29.7e9ac","598d20a3.9bea2"]]},{"id":"fa3f2e29.7e9ac","type":"http request","z":"b872cb4b.5a6448","name":"","method":"PUT","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":1570,"y":760,"wires":[["8d3bfd6c.d8f8"]]},{"id":"7a0a8426.78786c","type":"function","z":"b872cb4b.5a6448","name":"attempt 1 (using payload)","func":"var RightAscension = msg.payload.RightAscension\nvar Declination = msg.payload.Declination\n\nmsg.url = \"http://192.168.1.11:11111/api/v1/telescope/0/slewtocoordinatesasync\"\nmsg.payload = `RightAscension=${RightAscension}&Declination=${Declination}`\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1160,"y":760,"wires":[["9f3f7877.59ad98"]]},{"id":"8d3bfd6c.d8f8","type":"debug","z":"b872cb4b.5a6448","name":"V1 result","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1720,"y":760,"wires":[]},{"id":"a2750b93.af00f8","type":"inject","z":"b872cb4b.5a6448","name":"RightAscension 90 Declination 30","props":[{"p":"payload"},{"p":"payload.RightAscension","v":"90","vt":"num"},{"p":"payload.Declination","v":"30","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{}","payloadType":"json","x":870,"y":800,"wires":[["7a0a8426.78786c"]]},{"id":"fbd4311b.9c659","type":"function","z":"b872cb4b.5a6448","name":"set headers","func":"msg.headers = {\n \"accept\": \"application/json\",\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n}\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1390,"y":880,"wires":[["4ed0cca8.0db5a4","a789f57d.205a78"]]},{"id":"e6aab007.b9b42","type":"function","z":"b872cb4b.5a6448","name":"attempt 2 (using url params)","func":"var RightAscension = msg.payload.RightAscension\nvar Declination = msg.payload.Declination\n\nvar params = `RightAscension=${RightAscension}&Declination=${Declination}`\nmsg.url = \"http://192.168.1.11:11111/api/v1/telescope/0/slewtocoordinatesasync?\" + params;\nmsg.payload = \"\";\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1170,"y":880,"wires":[["fbd4311b.9c659"]]},{"id":"4ed0cca8.0db5a4","type":"http request","z":"b872cb4b.5a6448","name":"","method":"PUT","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":1570,"y":880,"wires":[["f241a6a9.027678"]]},{"id":"c48f3eda.259d6","type":"inject","z":"b872cb4b.5a6448","name":"RightAscension 0 Declination 90","props":[{"p":"payload"},{"p":"payload.RightAscension","v":"0","vt":"num"},{"p":"payload.Declination","v":"90","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{}","payloadType":"json","x":870,"y":860,"wires":[["e6aab007.b9b42"]]},{"id":"6b235dc3.8eb1e4","type":"inject","z":"b872cb4b.5a6448","name":"RightAscension 90 Declination 30","props":[{"p":"payload"},{"p":"payload.RightAscension","v":"90","vt":"num"},{"p":"payload.Declination","v":"30","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{}","payloadType":"json","x":870,"y":920,"wires":[["e6aab007.b9b42"]]},{"id":"f241a6a9.027678","type":"debug","z":"b872cb4b.5a6448","name":"V2 result","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1720,"y":880,"wires":[]},{"id":"598d20a3.9bea2","type":"debug","z":"b872cb4b.5a6448","name":"check headers and url and payload","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1300,"y":800,"wires":[]},{"id":"a789f57d.205a78","type":"debug","z":"b872cb4b.5a6448","name":"check headers and url","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1360,"y":920,"wires":[]}]

```

---

<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:** [13 March 2021 12:39 UTC](https://discourse.nodered.org/t/some-advise-by-using-http-request-node/42566/8 "2021-03-13T12:39:34Z")

</div>

uncheck return a json object in http request node.

---

<div class="post-metadata">

**Author:** ![calberts](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/calberts/32/34312_2.png) [@calberts](https://discourse.nodered.org/u/calberts)\
**Post date:** [18 March 2021 20:47 UTC](https://discourse.nodered.org/t/some-advise-by-using-http-request-node/42566/9 "2021-03-18T20:47:09Z")

</div>

All sorry for the late reaction and special all of you who directly replayed.  
i understand its no argument but i was to busy with work. Today i was able to test your suggestions

i like to inform you, that its working, thanks to you all.

```auto
﻿﻿[{"id":"4162b8d3.6fadb8","type":"ui_button","z":"55c1b3dc.91214c","name":"Goto ZeroPosition","group":"8e238b13.7c40b8","order":14,"width":0,"height":0,"passthru":false,"label":"<font size=\"+1\">Goto ZeroPosition</font>","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":150,"y":800,"wires":[["37d01ae9.869d66"]]},{"id":"8932f8e.c5c8888","type":"http request","z":"55c1b3dc.91214c","name":"PUT-REST-Telescope-slewtocoordinatesasync","method":"PUT","ret":"obj","paytoqs":"ignore","url":"http://192.168.1.11:11111/api/v1/telescope/0/slewtocoordinatesasync","tls":"","persist":false,"proxy":"","authType":"","x":680,"y":800,"wires":[["261e81ee.00f02e"]]},{"id":"37d01ae9.869d66","type":"change","z":"55c1b3dc.91214c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"RightAscension=0&Declination=90","tot":"str"},{"t":"set","p":"headers.Content-Type","pt":"msg","to":"application/x-www-form-urlencoded","tot":"str"},{"t":"set","p":"headers.accept","pt":"msg","to":"application/json","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":800,"wires":[["8932f8e.c5c8888"]]},{"id":"261e81ee.00f02e","type":"debug","z":"55c1b3dc.91214c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":930,"y":800,"wires":[]},{"id":"8e238b13.7c40b8","type":"ui_group","name":"ALPACA","tab":"dd962aa5.a268f8","order":2,"disp":true,"width":"8","collapse":true},{"id":"dd962aa5.a268f8","type":"ui_tab","name":"OCS","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

```

There was also thinking falure which i didn't account when the telescope is parked you cant slew you need first unpark the telescope.

This is is the new way ho to communicated with telescope with Alpaca  
[ascom alpaca api](https://ascom-standards.org/api/)  
#ASCOMALPACA #ALPACA

this are the items i have implemented yet i will share it below so others can use it also.

```auto
[{"id":"3096177c.ea0ea8","type":"ui_text","z":"55c1b3dc.91214c","group":"8e238b13.7c40b8","order":5,"width":0,"height":0,"name":"Dome-Shutter-txt","label":"<font size=\"+1\">RoR Shutter :</font>","format":"{{msg.payload}}","layout":"row-spread","x":990,"y":260,"wires":[]},{"id":"a2190f84.12cbf","type":"inject","z":"55c1b3dc.91214c","name":"Dome-Shutterstatus","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"10","crontab":"","once":true,"onceDelay":"0","topic":"","payload":"api/v1/dome/0/shutterstatus","payloadType":"str","x":140,"y":260,"wires":[["cf2bce93.449e8"]]},{"id":"cf2bce93.449e8","type":"http request","z":"55c1b3dc.91214c","name":"GET REST-Dome-Shutter-Status","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://192.168.1.9:6800/{{{payload}}}","tls":"","persist":false,"proxy":"","authType":"","x":410,"y":260,"wires":[["cd8ef741.aa72f8"]]},{"id":"cd8ef741.aa72f8","type":"function","z":"55c1b3dc.91214c","name":"","func":"rc = msg.statusCode;\nif ( (rc == \"EHOSTUNREACH\") || (rc == \"ETIMEDOUT\") ) {\n msg.payload=\"<font size=\\\"+2\\\" color=\\\"yellow\\\">N/A</font>\";\n } else if ( rc == 400 ) {\n msg.payload=\"<font size=\\\"+2\\\" color=\\\"yellow\\\">N/C</font>\";\n} else if ( rc == 200 ) {\n p=JSON.parse(msg.payload)\n if ( p.Value == 0 ) {\n msg.payload=\"<font size=\\\"+2\\\" color=\\\"white\\\">Open</font>\";\n } else if ( p.Value == 1 ) {\n msg.payload=\"<font size=\\\"+2\\\" color=\\\"lime\\\">Closed</font>\";\n } else if ( p.Value == 2 ) {\n msg.payload=\"<font size=\\\"+2\\\" color=\\\"orange\\\">Opening</font>\";\n } else if ( p.Value == 3 ) {\n msg.payload=\"<font size=\\\"+2\\\" color=\\\"orange\\\">Closing</font>\";\n } else if ( p.Value == 4 ) {\n msg.payload=\"<font size=\\\"+2\\\" color=\\\"red\\\">ERROR</font>\";\n }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":620,"y":260,"wires":[["6dddcf05.0dc41"]]},{"id":"6dddcf05.0dc41","type":"rbe","z":"55c1b3dc.91214c","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":830,"y":260,"wires":[["3096177c.ea0ea8"]]},{"id":"eca3b1c1.d4af6","type":"ui_text","z":"55c1b3dc.91214c","group":"8e238b13.7c40b8","order":9,"width":0,"height":0,"name":"Telescope-Tracking.txt","label":"<font size=\"+1\">Telescope Tracking :</font>","format":"{{msg.payload}}","layout":"row-spread","x":1000,"y":540,"wires":[]},{"id":"87d16c91.ef369","type":"comment","z":"55c1b3dc.91214c","name":"Telescope","info":"","x":180,"y":360,"wires":[]},{"id":"5b4dade.86af454","type":"ui_text","z":"55c1b3dc.91214c","group":"8e238b13.7c40b8","order":7,"width":0,"height":0,"name":"Telescope-Pier.txt","label":"<font size=\"+1\">Telescope PierSide :</font>","format":"{{msg.payload}}","layout":"row-spread","x":990,"y":460,"wires":[]},{"id":"747845ec.c6ecdc","type":"inject","z":"55c1b3dc.91214c","name":"Telescope-SideOfPier","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"10","crontab":"","once":true,"onceDelay":"0","topic":"sideofpier","payload":"api/v1/telescope/0/sideofpier","payloadType":"str","x":140,"y":460,"wires":[["d65a9d4f.561a6"]]},{"id":"d65a9d4f.561a6","type":"http request","z":"55c1b3dc.91214c","name":"GET-REST-Telescope-Pier","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://192.168.1.11:11111/{{{payload}}}","tls":"","persist":false,"proxy":"","authType":"","x":390,"y":460,"wires":[["46dc73ca.b7181c"]]},{"id":"46dc73ca.b7181c","type":"function","z":"55c1b3dc.91214c","name":"","func":"rc = msg.statusCode;\nif ( (rc == \"EHOSTUNREACH\") || (rc == \"ETIMEDOUT\") ) {\n msg.payload=\"<font size=\\\"+2\\\" color=\\\"yellow\\\">N/A</font>\";\n} else if ( rc == 400 ) {\n msg.payload=\"<font size=\\\"+2\\\" color=\\\"yellow\\\">N/C</font>\";\n} else if ( rc == 200 ) {\n p=JSON.parse(msg.payload)\n msg.payload=\"<font size=\\\"+2\\\" color=\\\"orange\\\">Unknown</font>\";\n if ( p.Value == 0 ) {\n msg.payload=\"<font size=\\\"+2\\\" color=\\\"lime\\\">East</font>\";\n } else if ( p.Value == 1 ) {\n msg.payload=\"<font size=\\\"+2\\\" color=\\\"lime\\\">West</font>\";\n }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":620,"y":460,"wires":[["5eaaeccb.f0ac34"]]},{"id":"254a5d6c.74ad12","type":"ui_text","z":"55c1b3dc.91214c","group":"8e238b13.7c40b8","order":6,"width":0,"height":0,"name":"Telescope-AtPark.txt","label":"<font size=\"+1\">Telescope Parked :</font>","format":"{{msg.payload}}","layout":"row-spread","x":1000,"y":420,"wires":[]},{"id":"a4c244f7.06b468","type":"inject","z":"55c1b3dc.91214c","name":"Telescope-AtPark","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"10","crontab":"","once":true,"onceDelay":"0","topic":"","payload":"api/v1/telescope/0/atpark","payloadType":"str","x":150,"y":420,"wires":[["8bbe44b9.8eabd8"]]},{"id":"8bbe44b9.8eabd8","type":"http request","z":"55c1b3dc.91214c","name":"GET-REST-Telescope-park","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://192.168.1.11:11111/{{{payload}}}","tls":"","persist":false,"proxy":"","authType":"","x":400,"y":420,"wires":[["97de4e3d.05ce"]]},{"id":"97de4e3d.05ce","type":"function","z":"55c1b3dc.91214c","name":"","func":"rc = msg.statusCode;\nif ( (rc == \"EHOSTUNREACH\") || (rc == \"ETIMEDOUT\") ) {\n msg.payload=\"<font size=\\\"+2\\\" color=\\\"yellow\\\">N/A</font>\";\n} else if ( rc == 400 ) {\n msg.payload=\"<font size=\\\"+2\\\" color=\\\"yellow\\\">N/C</font>\";\n} else if ( rc == 200 ) {\n p=JSON.parse(msg.payload)\n msg.payload=\"<font size=\\\"+2\\\" color=red>Yes</font>\";\n if ( p.Value == false ) {\n msg.payload=\"<font size=\\\"+2\\\" color=red>No</font>\";\n }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":620,"y":420,"wires":[["d8f2e7c1.6a2fa8"]]},{"id":"decb3adc.3a2c98","type":"ui_text","z":"55c1b3dc.91214c","group":"8e238b13.7c40b8","order":8,"width":0,"height":0,"name":"Telescope-Slewing.txt","label":"<font size=\"+1\">Telescope Moving :</font>","format":"{{msg.payload}}","layout":"row-spread","x":1000,"y":500,"wires":[]},{"id":"deb9fe9.65317","type":"inject","z":"55c1b3dc.91214c","name":"Telescope-Slewing","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"5","crontab":"","once":true,"onceDelay":"0","topic":"api/v1/telescope/0/slewing","payload":"api/v1/telescope/0/slewing","payloadType":"str","x":150,"y":500,"wires":[["20eea3e8.7befdc"]]},{"id":"20eea3e8.7befdc","type":"http request","z":"55c1b3dc.91214c","name":"GET-REST-Telescope-slew","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://192.168.1.11:11111/{{{payload}}}","tls":"","persist":false,"proxy":"","authType":"","x":400,"y":500,"wires":[["1e0dbe66.f31c02"]]},{"id":"1e0dbe66.f31c02","type":"function","z":"55c1b3dc.91214c","name":"","func":"rc = msg.statusCode;\nif ( (rc == \"EHOSTUNREACH\") || (rc == \"ETIMEDOUT\") ) {\n msg.payload=\"<font size=\\\"+2\\\" color=\\\"yellow\\\">N/A</font>\";\n} else if ( rc == 400 ) {\n msg.payload=\"<font size=\\\"+2\\\" color=\\\"yellow\\\">N/C</font>\";\n} else if ( rc == 200 ) {\n p=JSON.parse(msg.payload)\n msg.payload=\"<font size=\\\"+2\\\" color=\\\"lime\\\">No</font>\";\n if ( p.Value == true ) {\n msg.payload=\"<font size=\\\"+2\\\" color=\\\"orange\\\">Yes</font>\";\n }\n}\nreturn msg;","outputs":1,"noerr":0,"x":620,"y":500,"wires":[["2c9ad16.607962e"]]},{"id":"8364737b.8b7ea","type":"inject","z":"55c1b3dc.91214c","name":"Telescope-Tracking","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"5","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"api/v1/telescope/0/tracking","payloadType":"str","x":140,"y":540,"wires":[["f9500ac8.79c278"]]},{"id":"f9500ac8.79c278","type":"http request","z":"55c1b3dc.91214c","name":"GET-REST-Telescope-Tracking","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://192.168.1.11:11111/{{{payload}}}","tls":"","persist":false,"proxy":"","authType":"","x":410,"y":540,"wires":[["1abb18c2.03fd87"]]},{"id":"1abb18c2.03fd87","type":"function","z":"55c1b3dc.91214c","name":"","func":"rc = msg.statusCode;\nif ( (rc == \"EHOSTUNREACH\") || (rc == \"ETIMEDOUT\") ) {\n msg.payload=\"<font size=\\\"+2\\\" color=\\\"yellow\\\">N/A</font>\";\n } else if ( rc == 400 ) {\n msg.payload=\"<font size=\\\"+2\\\" color=\\\"yellow\\\">N/C</font>\";\n} else if ( rc == 200 ) {\n p=JSON.parse(msg.payload)\n msg.payload=\"<font size=\\\"+2\\\" color=\\\"orange\\\">No</font>\";\n if ( p.Value == true ) {\n msg.payload=\"<font size=\\\"+2\\\" color=\\\"lime\\\">Yes</font>\";\n }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":620,"y":540,"wires":[["39c4f7cc.120e68"]]},{"id":"42a6d543.788f6c","type":"catch","z":"55c1b3dc.91214c","name":"HostDown","scope":["d65a9d4f.561a6","8bbe44b9.8eabd8","20eea3e8.7befdc","f9500ac8.79c278"],"uncaught":false,"x":180,"y":800,"wires":[["e50f9d17.12517"]]},{"id":"e50f9d17.12517","type":"debug","z":"55c1b3dc.91214c","name":"","active":true,"tosidebar":false,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":350,"y":800,"wires":[]},{"id":"39c4f7cc.120e68","type":"rbe","z":"55c1b3dc.91214c","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":830,"y":540,"wires":[["eca3b1c1.d4af6"]]},{"id":"2c9ad16.607962e","type":"rbe","z":"55c1b3dc.91214c","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":830,"y":500,"wires":[["decb3adc.3a2c98"]]},{"id":"5eaaeccb.f0ac34","type":"rbe","z":"55c1b3dc.91214c","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":830,"y":460,"wires":[["5b4dade.86af454"]]},{"id":"d8f2e7c1.6a2fa8","type":"rbe","z":"55c1b3dc.91214c","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":830,"y":420,"wires":[["254a5d6c.74ad12"]]},{"id":"d3d202e6.6ad9d8","type":"http request","z":"55c1b3dc.91214c","name":"PUT-REST-Telescope-park","method":"PUT","ret":"txt","paytoqs":"ignore","url":"http://192.168.1.11:11111/api/v1/telescope/0/park","tls":"","persist":false,"proxy":"","authType":"","x":620,"y":580,"wires":[[]]},{"id":"4aa5d844.82e868","type":"ui_button","z":"55c1b3dc.91214c","name":"Park Telescope ","group":"8e238b13.7c40b8","order":10,"width":4,"height":1,"passthru":false,"label":"<font size=\"+1\">Park</font>","tooltip":"","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"str","topic":"","x":160,"y":580,"wires":[["d3d202e6.6ad9d8"]]},{"id":"30e9ee62.f81dd2","type":"http request","z":"55c1b3dc.91214c","name":"PUT-REST-Dome-shutter-poweron","method":"PUT","ret":"txt","paytoqs":"ignore","url":"http://192.168.1.9:6800/api/v1/dome/0/poweron","tls":"","persist":false,"proxy":"","authType":"","x":740,"y":80,"wires":[[]]},{"id":"494b73a9.205c44","type":"ui_button","z":"55c1b3dc.91214c","name":"Ropen","group":"8e238b13.7c40b8","order":3,"width":4,"height":1,"passthru":false,"label":"<font size=\"+1\">Roof 0pen</font>","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":170,"y":180,"wires":[["2f11568d.21a302"]]},{"id":"2f11568d.21a302","type":"http request","z":"55c1b3dc.91214c","name":"PUT-REST-Dome-shutteropen","method":"PUT","ret":"txt","paytoqs":"ignore","url":"http://192.168.1.9:6800/api/v1/dome/0/openshutter","tls":"","persist":false,"proxy":"","authType":"","x":410,"y":180,"wires":[[]]},{"id":"582142a3.de27b4","type":"http request","z":"55c1b3dc.91214c","name":"PUT-REST-Dome-shutter-poweroff","method":"PUT","ret":"txt","paytoqs":"ignore","url":"http://192.168.1.9:6800/api/v1/dome/0/poweroff","tls":"","persist":false,"proxy":"","authType":"","x":740,"y":120,"wires":[[]]},{"id":"38580415.ca19dc","type":"ui_button","z":"55c1b3dc.91214c","name":"Rclose","group":"8e238b13.7c40b8","order":4,"width":4,"height":1,"passthru":false,"label":"<font size=\"+1\">Roof Close</font>","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":170,"y":220,"wires":[["caca5c71.1e464"]]},{"id":"caca5c71.1e464","type":"http request","z":"55c1b3dc.91214c","name":"PUT-REST-Dome-shutterclose","method":"PUT","ret":"txt","paytoqs":"ignore","url":"http://192.168.1.9:6800/api/v1/dome/0/closeshutter","tls":"","persist":false,"proxy":"","authType":"","x":410,"y":220,"wires":[[]]},{"id":"5c358de5.3cbf84","type":"ui_switch","z":"55c1b3dc.91214c","name":"","label":"Roof power off / on","tooltip":"","group":"8e238b13.7c40b8","order":1,"width":5,"height":1,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":150,"y":100,"wires":[["4e11a3fb.4d78c4","8a44c5c2.b51148"]]},{"id":"4e11a3fb.4d78c4","type":"switch","z":"55c1b3dc.91214c","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":370,"y":100,"wires":[["30e9ee62.f81dd2"],["11b68e35.d8dcc2"]]},{"id":"11b68e35.d8dcc2","type":"change","z":"55c1b3dc.91214c","name":"o to 1","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":120,"wires":[["582142a3.de27b4"]]},{"id":"2b68f9b7.7457d6","type":"comment","z":"55c1b3dc.91214c","name":"Role of Roof","info":"","x":170,"y":40,"wires":[]},{"id":"8a44c5c2.b51148","type":"function","z":"55c1b3dc.91214c","name":"Color function","func":"switch (msg.payload) {\n\ncase 1 : \n msg.color = \"Green\";\n msg.payload = \"Aan\";\n break;\n \ncase 0 : \n msg.color = \"Red\";\n msg.payload = \"Uit\";\n break;\n \ndefault : \n msg.color = \"Gray\";\n msg.payload = \"not set\";\n break;\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":420,"y":40,"wires":[["336a8046.93942"]]},{"id":"336a8046.93942","type":"ui_text","z":"55c1b3dc.91214c","group":"8e238b13.7c40b8","order":2,"width":3,"height":1,"name":"Dak Power Status","label":"STATUS :","format":"<font color= {{msg.color}} > {{msg.payload}} </font>","layout":"row-left","x":630,"y":40,"wires":[]},{"id":"54a887ec.0f59a","type":"ui_button","z":"55c1b3dc.91214c","name":"UnPark Telescope","group":"8e238b13.7c40b8","order":11,"width":4,"height":1,"passthru":false,"label":"<font size=\"+1\">UnPark</font>","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":150,"y":620,"wires":[["a91b65fa.a077a8"]]},{"id":"a91b65fa.a077a8","type":"http request","z":"55c1b3dc.91214c","name":"PUT-REST-Telescope-UnPark","method":"PUT","ret":"txt","paytoqs":"ignore","url":"http://192.168.1.11:11111/api/v1/telescope/0/unpark","tls":"","persist":false,"proxy":"","authType":"","x":630,"y":620,"wires":[[]]},{"id":"e012f7c8.b7d","type":"http request","z":"55c1b3dc.91214c","name":"PUT-REST-Telescope-Tracking","method":"PUT","ret":"txt","paytoqs":"ignore","url":"http://192.168.1.11:11111/api/v1/telescope/0/tracking","tls":"","persist":false,"proxy":"","authType":"","x":630,"y":660,"wires":[[]]},{"id":"8f2b600a.afa79","type":"ui_button","z":"55c1b3dc.91214c","name":"Tracking-On","group":"8e238b13.7c40b8","order":12,"width":4,"height":1,"passthru":false,"label":"<font size=\"+1\">Tracking-On</font>","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":170,"y":660,"wires":[["27f283b.48d91fc"]]},{"id":"4162b8d3.6fadb8","type":"ui_button","z":"55c1b3dc.91214c","name":"Goto ZeroPosition","group":"8e238b13.7c40b8","order":14,"width":0,"height":0,"passthru":false,"label":"<font size=\"+1\">Goto ZeroPosition</font>","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":150,"y":740,"wires":[["37d01ae9.869d66"]]},{"id":"8932f8e.c5c8888","type":"http request","z":"55c1b3dc.91214c","name":"PUT-REST-Telescope-slewtocoordinatesasync","method":"PUT","ret":"txt","paytoqs":"ignore","url":"http://192.168.1.11:11111/api/v1/telescope/0/slewtocoordinatesasync","tls":"","persist":false,"proxy":"","authType":"","x":680,"y":740,"wires":[[]]},{"id":"37d01ae9.869d66","type":"change","z":"55c1b3dc.91214c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"RightAscension=0&Declination=90","tot":"str"},{"t":"set","p":"headers.Content-Type","pt":"msg","to":"application/x-www-form-urlencoded","tot":"str"},{"t":"set","p":"headers.accept","pt":"msg","to":"application/json","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":740,"wires":[["8932f8e.c5c8888"]]},{"id":"27f283b.48d91fc","type":"change","z":"55c1b3dc.91214c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Tracking=true","tot":"str"},{"t":"set","p":"headers.Content-Type","pt":"msg","to":"application/x-www-form-urlencoded","tot":"str"},{"t":"set","p":"headers.accept","pt":"msg","to":"application/json","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":660,"wires":[["e012f7c8.b7d"]]},{"id":"51869a66.cb35f4","type":"http request","z":"55c1b3dc.91214c","name":"PUT-REST-Telescope-Tracking","method":"PUT","ret":"txt","paytoqs":"ignore","url":"http://192.168.1.11:11111/api/v1/telescope/0/tracking","tls":"","persist":false,"proxy":"","authType":"","x":630,"y":700,"wires":[[]]},{"id":"7f6554cf.274ebc","type":"ui_button","z":"55c1b3dc.91214c","name":"Tracking-Off","group":"8e238b13.7c40b8","order":13,"width":4,"height":1,"passthru":false,"label":"<font size=\"+1\">Tracking-Off</font>","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":170,"y":700,"wires":[["fa4a55f2.0a2218"]]},{"id":"fa4a55f2.0a2218","type":"change","z":"55c1b3dc.91214c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Tracking=False","tot":"str"},{"t":"set","p":"headers.Content-Type","pt":"msg","to":"application/x-www-form-urlencoded","tot":"str"},{"t":"set","p":"headers.accept","pt":"msg","to":"application/json","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":700,"wires":[["51869a66.cb35f4"]]},{"id":"8e238b13.7c40b8","type":"ui_group","name":"ALPACA","tab":"dd962aa5.a268f8","order":2,"disp":true,"width":"8","collapse":true},{"id":"dd962aa5.a268f8","type":"ui_tab","name":"OCS","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

```

Again thanks for your support the excellent explanation

Chris Status Solved

---

<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:** [1 April 2021 20:47 UTC](https://discourse.nodered.org/t/some-advise-by-using-http-request-node/42566/10 "2021-04-01T20:47:36Z")

</div>

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