Hello .. the problem is not very clear .. so you get a reply back as an empty string ?
it all depends on your device's documentation .. do you have a link ?
also have you tried in the Function node (just before your http-request)
let tag = msg.payload.deveuil;
let valor = msg.payload.Comptador;
let datahora = msg.payload.DataHora;
msg.url = `http://192.168.X.X/apienergia/funcions.php?funcio=updateComptadorGET&tag=${tag}&valor=${valor}&datahora=${datahora}`
msg.method = "POST"
return msg;
ps. in the test, clear the url from the http-request node since we are sending it from the function
You have to study the PHP code and see what it does
a quick search for $_POST
An associative array of variables passed to the current script via the HTTP POST method when using application/x-www-form-urlencoded or multipart/form-data as the HTTP Content-Type in the request.
We tried urlencoded .. try multipart/form-data
im not sure of the syntax but there is an example at the end of the http-request node's help tab.
maybe ..
let tag = msg.payload.deveuil;
let valor = msg.payload.Comptador;
let datahora = msg.payload.DataHora;
msg.url = `http://192.168.X.X/apienergia/funcions.php?funcio=updateComptador`
msg.method = "POST"
msg.headers = { "Content-type": "multipart/form-data" }
msg.payload = {
"tag": { "value": tag },
"valor": { "value": valor },
"datahora": { "value": datahora }
}
return msg;
ps1. also check why it returns a 404 .. do you have the IP and url correct ?
ps2. are you sure its a POST request .. maybe its method is GET ?
it not common and usually request that send data are POST but worth to try.
... you simply need to create a URL with query parameters.
let tag = msg.payload.deveuil;
let valor = msg.payload.Comptador;
let datahora = msg.payload.DataHora;
msg.url = `http://192.168.X.X/apienergia/funcions.php?funcio=updateComptador&tag=${tag}&valor=${valor}&datahora=${datahora}`
msg.method = "GET"
//Should be no harm including values in payload...
msg.payload = { "tag": tag, "valor": valor, "datahora": datahora }
//... but you can probably delete the above line if needed
return msg;
Send the output of the function to a HTTP Request node (leave the URL field blank so that it is populated by the value generated in msg.url
Also, send the output of the function to a debug node (set to show complete msg) and show us what you get in the debug sidebar.
You didn't use the code I wrote. It still has GET in the middle. And, the code for the url string is a regular string '' instead of a template string ``
I dont think its working because of GET in the url .. ?funcio=updateComptadorGET ..
you get a reply statusCode 200 because the msg.method is "GET"
but have you confirmed that the PHP executed as it should ?
the php code you shared says if funcio === "updateComptador"
so if you have in url .. ?funcio=updateComptadorGET .. i wonder if it executes