How to send the input from textfield via flutter and node-red

I'm trying to send the data from flutter through node-red to the database by using http post. The database was updated but they showed undefined in every column.

This is my code in flutter:

Future registerCus(String first_name,String last_name, String phone_no,String email, String username,String password) async {
String url = "http://my IP address:1880/register?first_name=c1&last_name=c2&phone_no=c3&email=c4&username=c5&password=c6";
url = url.replaceFirst("c1", first_name);
url = url.replaceFirst("c2", last_name);
url = url.replaceFirst("c3", phone_no);
url = url.replaceFirst("c4", email);
url = url.replaceFirst("c5", username);
url = url.replaceFirst("c6", password);
var result = await;
var data = json.encode(result.body);, body: data, headers: {"Content-Type": "application/json"})
.then((value) => print(value));

and the code below is a function in node-red:

var user_id = msg.payload.user_id;
var username = msg.payload.username;
var password = msg.payload.password;
var first_name = msg.payload.first_name;
var last_name = msg.payload.last_name;
var phone_no = msg.payload.phone_no;
var email =;

var sql = "insert into account (user_id,first_name,last_name,phone_no,email,username,password) ";
sql += "value(null,'c1','c2','c3','c4','c5','c6')";
sql = sql.replace('c1',first_name);
sql = sql.replace('c2',last_name);
sql = sql.replace('c3',phone_no);
sql = sql.replace('c4',email);
sql = sql.replace('c5',username);
sql = sql.replace('c6',password);

msg.topic = sql;
return msg;

these are the result that went into the database:
Screen Shot 2020-10-17 at 16.21.54
Screen Shot 2020-10-17 at 16.23.57

Can we see a debug of the output from the http in node?

Here you are

can you set the debug to see the full msg object?

I don't know how to set it :sob:

as above
also while you are at it a screenshot of the settings in the http in node

Please expand the objects payload and req and post again.

Screen Shot 2020-10-17 at 17.06.37

Screen Shot 2020-10-17 at 17.06.44

Screen Shot 2020-10-17 at 17.06.55

wrong payload , i need the top one in the image.

can you expand query from the last image

This one?
Screen Shot 2020-10-17 at 17.13.04

Add this to the top of your node-red function code

if (msg.req.method === "POST") {msg.payload = msg.req.query}

I did and this is showed
Screen Shot 2020-10-17 at 17.16.12

Screen Shot 2020-10-17 at 17.16.26

add a debug after the function node.

oh, it's working now. Thanks a lot :pray: :pray:

The http in node when set to POST, seems to not add msg.payload properties, . The code i gave moves them from msg.req.query to msg.payload.

have a read here to learn more about working with messages

ohh, I got it. I will learn more. Thank you so much for helping me fix this. :joy: I'm stuck for a while

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