Go Down

Topic: How to parse HTTP POST request on Yun (Read 103 times) previous topic - next topic


Hello everyone,

I am trying to send a POST call to my Arduino Yun, and I don't know how to parse the POST body.

When I make a POST call to: 


with body:


I receive the call, but I can't retrieve the request body from the POST call.

I started from the Bridge example (which works), but that only covers the GET call.

Is there an example for receiving POST requests on Arduino Yun?

Thank you,


The Yun has two processors - the '32U4 processor that runs your sketch, and an ARM processor that runs Linux. Between the two of them, the Linux side is many times more powerful.

While there are some examples of handling GET requests in a sketch, they suffer from the limitation of being very slow and cumbersome: the request first comes into the Linux side, it gets pre-processed by the Linux network software, and the URL gets extracted and sent to the sketch over the relatively slow serial port that is between the two processors. The sketch receives the URL (and only the URL) and sends back a response over the serial port. Linux receives that response, wraps it up in a formal HTTP response packet, and sends it back to the requesting machine. It's a lot of overhead, and quite slow.

My suggestion is to do all of the network processing on the Linux side. One of the simpler ways to do that is to use a Python application framework like Bottle or Flask. I've written a couple Bottle application, and while it's a little bit of a different way of thinking, I found it pretty easy to catch on.

If you do it on the Linux side, you get much more powerful tools, it's easier to write, and it will run much faster. Once you received and extracted the data, you can send that up to the sketch (I like to use a Process object) and let it do whatever needs to be done.

Ive tried a few different ways to organize projects, and what works best for me is to do as much of the processing as possible on the Linux side, and make the sketch a slightly intelligent I/O processor.

Go Up