Hello Guys,
i'm new to the Node-RED Community, and also new with the scripting and logical connecting of Nodes. Hope we are having a nice time together.
I'm actually doing an project to get a degree as a state-certified technician in Germany.
My task is to connect a collaborating robot (working with REST-API via different HTTP-Requests like POST, PUT, GET, DELETE...) with NodeRED.
Here an Overview from the API (by the manufracturer website)
Overview Choreograph REST API
Nearly all of the requests i did in the NodeRED flow work... excepted this one, where the toolpath gets started by the "controls" unit.
I'm trying to set up a HTTP-request, with payload formatted in JSON.
This is happening in the following flow:
[{"id":"3b67977c.a53c08","type":"debug","z":"84e0de5f.c40b1","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":790,"y":820,"wires":[]},{"id":"4030c52c.c2c29c","type":"inject","z":"84e0de5f.c40b1","name":"Start Toolpath","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":820,"wires":[["31727a2c.05a026"]]},{"id":"64d9243f.b7be7c","type":"http request","z":"84e0de5f.c40b1","name":"HTTP-REQUEST","method":"use","ret":"obj","paytoqs":"ignore","url":"http://eva-perfectbeijingmiller.local/api/v1/controls/run","tls":"","persist":false,"proxy":"","authType":"","x":550,"y":820,"wires":[["3b67977c.a53c08"]]},{"id":"31727a2c.05a026","type":"function","z":"84e0de5f.c40b1","name":"SETTING REQUEST","func":"msg.method = \"POST\"\nmsg.url = \"http://eva-perfectbeijingmiller.local/api/v1/controls/run\"\nmsg.headers = {}\nmsg.headers[\"content-type\"] = \"application/json\"\nmsg.headers[\"Authorization\"] = \"Bearer \"+ flow.get('token');\n\nvar teach = teach\nvar loop = loop\nmsg.payload = [{\n \"mode\":teach,\n \"loop\":1\n}]\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","x":340,"y":820,"wires":[["64d9243f.b7be7c"]]}]
I already triggered the flow through the timestamp. Here is my answer by the debug node on the right field:
it seems like NodeRED and the REST-API aren't speaking the same JSON.
There is another noticeable thing...
when im sending the note without setting these definitions:
var teach=teach
var loop=loop
the debug node says:
7.4.2021, 21:22:10 node: SETTING REQUEST
function : (error)
"ReferenceError: teach is not defined (line 7, col 12)"
Trying the wildest constelations of setting '' quotes and using different brackets, but there was no success.
Thanks for your help guys, im really despaired already.
friendly greetings from Germany
Nils