Another http post thread :)

hello all, i am trying to do a post to a local device (linux machine running a server)
I want to pretty much send a command like this :

curl -X POST http://localhost:5000/api/device/port?state=on

in this case localhost should be

The code i have is :`// MyAgent

function send_to_server(server_server_ip="", server_switch="", switch_state="")
server.log("–>server: " + server_server_ip + “,” + server_switch + “-> " + switch_state); // body for testing
local link_to_send = “http://” + server_server_ip+”:5000/api/device/" + server_switch
server.log("–>server: " + link_to_send);
local data = {state=switch_state}; + http.urlencode(data), {}, “”).sendasync(function(res) {
if (res.statuscode != 200) {
server.error("serverfailed: " + res.statuscode + " => " + res.body);

device.on(“server”, function(data)
//take from device
send_to_server(data.server_server_ip, data.server_switch, data.switch_state); //send to function to call server

i can verify that all 3 variables send from my code are correct ie:

data.server_server_ip =
data.server_switch = port
data.switch_state = on

This is example code, i have tried different solutions but cannot make it work.
Doing a post from another linux machine to the works just fine.
I also tried requestbin and there it seemed to work fine (well at least one of the ways i tried)

So my questions are:

  1. Do i have the code correct?
  2. I dont think thats the case but maybe the imp cannot do a POST/GET to a local IP???

Thanks in advance

The imp is not posting, the agent is, and the agent is out there in the cloud so a local address means nothing to it. Either you need to expose your target machine to the internet so the agent can see it, or pass the data through a common repository out there such as Xively which the target machine can read from.

i see so thats why a local address wont work… ok i will go a different rout then, thanks for your answer