I want to send Data from PLC to an API

I want to send data on an API from my PLC.

Here is my flow:

[{"id":"4fe68f34.52a3a","type":"function","z":"787783f2.48923c","name":"Send Data to API ","func":"msg.method = "GET";\nmsg.url = "https:/xyz.net/app/storeData?param1=" +(msg.payload.MoistureatReel)+"&param2=param2value&param3=param3value&param4=param4value&param5=param5value&param6=param6value&param7=param7value&param8=param8value&param9=param9value&param10=param10value";\nreturn msg; ","outputs":1,"noerr":0,"initialize":"","finalize":"","x":366,"y":252,"wires":[["2bb41ad7.354706"]]}]


Instead of msg.payload.MoistureatReel what should I write/change so that the value at that PLC Variable we get here in that API.

Some info required to answer question
what api?
what plc?
what is the incomming or input data?
what should the finished url look like, is there an example?
what values does the api take in the url?
where is your flow? as you just supplied a single node.

The values coming out of PLC are as shown in image below. PLC I am using is Siemens 1200, Input. It takes Data in any format i have manually wriiten values and send it but what should i write in place of " +String(msg.payload.MoistureatReel)+ " so that my value coming at parameter **1 2 ** reflects when i update this API.

msg.payload["Moisture at Reel"]

as there are spaces in the name.

I have tried this but doesn't work

Try the format i showed below the quote.

It shows undefined

Not according to your image. You must have over written it. add debug before function to check it exists. I can not say more as i have no more info.

7

![6|480x344]

When i use like this "+context.global.MoistureatReel+" this thing works but i need to individually take 50 S7 Nodes 50 Function Nodes and write in the function nodes individually context.global.xxx

which is not a feasable solution if there are more parameters to transfer

6

Image of S7 Node

Again i ask for a debug from just before function showing complete message object.

Means after the timestamp node?

I am new to this Node red. I am not getting what you are saying.

How would i know after which node, you still have not supplied a flow. I require a debug of info that goes into function, which ever node is before it is the one you should add the debug to, and do make sure it's the complete message object.

You should read this and watch the videos it will help you understand more.
https://nodered.org/docs/user-guide/messages

I will share you the flow


[{"id":"5ad8f653.eb1298","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"9eafd082.f8802","type":"s7 in","z":"5ad8f653.eb1298","endpoint":"24609e1b.f132d2","mode":"all","variable":"MoistureatReel","diff":true,"name":"PLC Data","x":240,"y":84,"wires":[["bebafa0.2deaf08"]]},{"id":"bebafa0.2deaf08","type":"debug","z":"5ad8f653.eb1298","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":307,"y":175,"wires":},{"id":"4fbe13b6.a48dfc","type":"inject","z":"5ad8f653.eb1298","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":168,"y":288,"wires":[["cbdc8747.162cc8"]]},{"id":"a67295c4.a7a508","type":"http request","z":"5ad8f653.eb1298","name":"","method":"use","ret":"txt","paytoqs":false,"url":"","tls":"","proxy":"","authType":"","x":574,"y":288,"wires":[["cedf224e.58c2c"]]},{"id":"cedf224e.58c2c","type":"debug","z":"5ad8f653.eb1298","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":742,"y":288,"wires":},{"id":"cbdc8747.162cc8","type":"function","z":"5ad8f653.eb1298","name":"Send Data to API ","func":"msg.method = "GET";\nmsg.url = "https://xyz.net/app/storeData?param1=\" +msg.payload.MoistureatReel+ "&param2=param2value&param3=param3value&param4=param4value&param5=param5value&param6=param6value&param7=param7value&param8=param8value&param9=param9value&param10=param10value";\nreturn msg; ","outputs":1,"noerr":0,"initialize":"","finalize":"","x":378,"y":288,"wires":[["a67295c4.a7a508"]]},{"id":"24609e1b.f132d2","type":"s7 endpoint","transport":"iso-on-tcp","address":"192.168.200.50","port":"102","rack":"0","slot":"1","localtsaphi":"01","localtsaplo":"00","remotetsaphi":"01","remotetsaplo":"00","connmode":"rack-slot","adapterauto":true,"adapterport":"","busaddr":"2","adapteraddr":"0","cycletime":"500","timeout":"1500","verbose":"default","name":"","vartable":[{"addr":"MR4","name":"MoistureatReel"},{"addr":"MR8","name":"Machine Speed"},{"addr":"MR12","name":"Storage Tower Level"},{"addr":"MR16","name":"Broke Tower Level"},{"addr":"MR20","name":"Turbine Inlet Pressure"},{"addr":"MR24","name":"Turbine Inlet Temperature"},{"addr":"MR28","name":"Bleed Flow"},{"addr":"MR32","name":"Extraction Flow"},{"addr":"MR68","name":"Paper at Size Press"},{"addr":"MR72","name":"Paper at Shoe Press"},{"addr":"MR76","name":"Paper at Dryer 1"},{"addr":"MR80","name":"Paper at Dryer 2"},{"addr":"MR84","name":"Paper at Dryer 3"}]}]


Please read

Try importing the flow you just posted.

I asked for a debug, you post a flow, I can not help if you do not answer the questions and supply the info. I do not have access to the info(msg) even if i have a copy of the flow.

Please make me understand what is debug???

I supplied links if you had bothered to read them you would know what a debug is. please read and then post a debug of the incoming data
https://nodered.org/docs/user-guide/messages#understanding-the-structure-of-a-message
https://nodered.org/docs/user-guide/nodes#debug

that image is from a debug node so you have used one before, and the green node in the first image is a debug node.

Also watch this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.