Arduino Yun REST API not working from inside Yun, only from external device

Hi, I am trying to control the ATmega32u4 in Yun from a Python script running in the same Yun (AR9331) .

I am using the REST approach to achieve this, and wrote a simple sketch for ATmega32u4 to accept REST commands using the "Examples > Bridge > Bridge" sketch as a template.

It works ok as long as I send the commands using a browser from an external device (computer) like the following: which case the servo moves to the specified position.

But if I issue the commands from inside the Linux-side of the Arduino nothing happens. I have tried using Linux terminal commands like:

curl localhost/arduino/servo/20
curl localhost:5555/arduino/servo/20
curl -o a.txt http://localhost:5555/arduino/servo/20
wget -p http://localhost:5555/arduino/servo/20
wget -p http://localhost/arduino/servo/20

Some commands show an "Error 401", others show no error, but in either case the servo doesn't move.

Also inside Arduino I wrote a small python script:

import urllib2

Which also gives an "Error 401".

I haven't found a single example in the internet of using the REST approach from inside Arduino Terminal in several hours of searching. Every-time the examples show the case of using REST from an external browser.

Can anyone point me to a solution for being able to control the ATmega32u4 of YUN from a Python script running inside Yun?



401 Unauthorized (RFC 7235)

Similar to 403 Forbidden, but specifically for use when authentication is required and has failed or has not yet been provided. The response must include a WWW-Authenticate header field containing a challenge applicable to the requested resource. See Basic access authentication and Digest access authentication.

turn off the password protection when testing locally,

Did you try replacing localhost for the ip?


curl http://root:<password>@localhost/arduino/servo/20

There is no need to turn off security globally.