I am trying to send information to the controller using node-red from a postman put command. It works fine if all the values are integers in the ProductId string but as soon as I add a character I get an “unexpected toke” error.
I am trying to place the ProductId into index 1 of table sChamber_TestInformation in the controller.
String tables can accept two formats of data: JavaScript arrays, or JavaScript strings containing JSON of an array of strings – in either case the data must come in as an array, even if it is a single element. The reason for this is that the string value will be parsed as JSON by the JSON.parse() function, so the work around would look something like this for a JavaScript array with a single element:
var ProductionID = ['234t5234'];
or this for a JavaScript string of a JSON-formatted array with a single string element:
var ProductionID = '["234t5234"]';
But if you want to work with the value you have you can just move it into an array with a function or change node, and then change the PAC write node to use msg.payload:
msg.payload = [msg.payload.ProductionId];
3 Likes
Thank you for the help, that did the trick