Home Community Blog Buy Now
Blog

Misty Community Forum

SendExternalrequest not working for local server

Hi,

I am trying to send an external request to my local server and cannot seem to get it working. It works for other servers, ex google.

Here is the code:
var url = “http://192.168.1.107:80/status/setobjectdetected?description=” + data.PropertyTestResults[0].PropertyParent.Description.toString() + “&confidence=” + data.PropertyTestResults[0].PropertyParent.Confidence.toString();

misty.Debug("URL=>" + url);



try{

misty.SendExternalRequest("GET",url);

} catch (e) {

    misty.Debug("ERROR=>" + e);

}

Sample url: http://192.168.1.107:80/status/setobjectdetected?description=bed&confidence=0.572007239

Can SendexternalRequest access a server via IP address?

Thanks,

Wes

Hi @wlaubach64,

Misty can ping another device that is on the same local network with misty.SendExternalRequest() command.
To double check, I did a quick test…
I have two Misty’s with me and tried to change led of one Misty form the other.
Both the commands below worked for me.

misty.SendExternalRequest("POST", "http://10.0.0.18/api/led?red=20&green=10&blue=230");
misty.SendExternalRequest("POST", "http://10.0.0.18/api/led", null, null, JSON.stringify({"red": 255,"green": 50,"blue":0}));

Could you share the Error that gets printed from misty.Debug("ERROR=>" + e);

And just to be 100% sure the other side is working as expected…

  1. Have you also tried hitting something like "http://192.168.1.107:80/status/setobjectdetected?description=Huaman&confidence=52" from your browser/postman/python to verify that you see the expected output on your sever side?
  2. The use case feel more like a “POST” and not a “GET” to me – Is the GET usage correct here ?

CP [• •]

Hi,

I have tried POST and GET. The GET was just my latest try to debug.The url works from a browser and with POSTMAN.

I dont seem to be getting an error on the call, the misty.debug never gets printed. And if i have a callback, it never gets called.

Is there a way i can ping the server?

Wes

Good that everything works on postman and browser :slight_smile:
Could you share with me the whole js code (with the callback) so I can take a look at it.
cp@mistyrobotics.com

A couple questions regarding the set up:

  1. Is the robot on the same network as the server?

  2. Are the server and the device being used to test with a browser and postman different devices? If they are the same device make sure the server is set up to accept external requests.

With regards to your ping question you can attempt to ping the server by doing the following:

  1. Open a command prompt and ssh to the robot ssh administrator@<ROBOT IP ADDRESS> - It will ask for the password that came on the robot on the bottom

  2. You can now use all the tools available on windows command line, including the ping command to try to ping the server you’re using

Thank you everyone for your help. The following code fixed the problem:

var url = “http://192.168.1.107:80/status/setobjectdetected?description=” + data.PropertyTestResults[0].PropertyParent.Description.toString() + “&confidence=” + data.PropertyTestResults[0].PropertyParent.Confidence.toString();

   misty.Debug("URL=>" + url);



try{



misty.SendExternalRequest("POST", url, null, null, JSON.stringify({"description":"TEST", "confidence": ".025"}));

} catch (e) {

    misty.Debug("ERROR=>" + e);

}

I had to have it on the url and in the SendExternalRequest.

Thank you for your help.

Wes

1 Like

Awesome !! Glad that worked :slight_smile: