Thursday, 9 June 2016

How to use Arduino Yun HttpClient to send POST requests

----
One way is by Yunclient,

https://www.element14.com/community/thread/41630/l/arduino-yun-sending-data-to-ws-via-post?displayFullThread=true

http://forum.arduino.cc/index.php?topic=226602.0

however Yunclient.h is already retired.

----
Another ways is by use curl:

you need create a curl command as a string and run it by shell:

http://starter-kit.nettigo.eu/2014/arduino-yun-sending-data-thingspeak-post/

----
people already  made this api for arduino (they just didn't put it into the examples):

https://groups.google.com/a/arduino.cc/forum/#!topic/developers/_hFVHsTqgWU
https://github.com/arduino/Arduino/pull/2107

sourcecode is here:

Bridge/src/HttpClient:


unsigned int HttpClient::post(String &url, String &data) {
    return post(url.c_str(), data.c_str());
}

unsigned int HttpClient::post(const char *url, const char *data) {
  begin("curl");
  if (insecure) {
    addParameter("-k");
  }
  addParameter("--request");
  addParameter("POST");
  addParameter("--data");
  addParameter(data);
  addHeader();
  addParameter(url);
  return run();
}


No comments:

Post a comment