Arduino HTTP API examples updated!

HTTP API examples just got a big update:

If there’s anyone with Arduino GSM shield - could you please check if it works for you?
Thank you!



I’ve been looking for something like this. I do a lot of work with data collection with Xively. Very good but the API key is a pain as it needs a header sent separately rather than in the URL like Thingspeak. I did raise a request to see if the Blynk webhooks could be extended to support the header function of the HTTP get/put calls but not had anything back so far.

Does by chance the library you have published handle header?

Here is what I do normally for the Yun and VBA respectively. But in the meantime I’ll give the library a bash on my esp8266:

apiString = F(“X-ApiKey: “);
apiString += APIKEY;
Process xively;
// form the string for the URL parameter:
url = F(“”);
url += sFeed;
url += F(”/datastreams/”);
url += dataStream;
url += F(".csv");
// Send the HTTP GET request to

This is what it looks like using VBA:
Dim PutData As String
Dim MyRequest As Object
feed = “96473”
PutData = “8,” + “2013-01-27T00:00:00Z,” + “0” + vbCrLf

Set MyRequest = CreateObject(“WinHttp.WinHttpRequest.5.1”)
MyRequest.Open “PUT”, “” + feed + “.csv”
MyRequest.setRequestHeader “X-PachubeApiKey”, “blahblah”
MyRequest.setRequestHeader “Content-Length”, Len(PutData)

’ Send Request.
MyRequest.send (PutData)

Ah I see what you are doing now. This is not a general thing for HTTP for ESP8266 it is for your Blynk API. In any case it has introduced me to the Blynk API :slight_smile:

However, do you know how the ESP8266wifi library can be used to do a header as per my requirement above and also is there a thought about extending the Blynk webhooks to handle headers?

You can do exactly the same as you would do with an Arduino regarding headers within your Blynk sketch but outside of Webhooks. You might be able to use Google scripting to send the header and then interface with the script via webhooks.

Hi. Thanks for getting back to me. I’ll detail the context of my challenge to illustrate why I asked the question. Please don’t worry if it is going to take up too much of your time - just if you have some quick kick starts for me.

  1. For a couple of years now I have been using the Yun and the access to the lunix, VBA and java to get and put data to Xively. The first 2 options as per the code examples above. All works fine within the memory constraints of the Arduino Yun so far.
  2. Then along comes the fantastic Blynk. When I add Blynk to the Yun sketches I am maxing the programme memory and making the HTTP calls really unstable. It is definitely a memory thing.
  3. So I want to find a way out of this:
    a) Drop my use of the access to Linux (process function and curl statement) in the Yun and try to get Blynk webhooks to do it - but webhooks will need to be able to deal with the API Key via headers. Hence my request for Blynk to look at that option. If I can drop the Yun/Process stuff from my sketch this would free up loads of memory for more code with Blynk. You mentioned google scripts which I am unfamiliar with - can you give me a quick kickstart/links to get me going with this. I sort of see what you mean but help would be appreciated.
    b) Drop the Yun completely and try to use a generic ESP8266 board with more memory so I can do the Xively calls and blynk in the same script without the need for Blynk webhooks. But my challenge there is trying to find the ESP8266wifi library commands to support the use of headers. Hence my question to you about your knowledge of that library.

Any pointers welcome but only if it won’t drain your time.

If the Yun is short of memory buy a 1MB ESP for a few dollars. WeMos D1 Mini Pro at $5 would be my choice. 1MB programmable memory and 15MB storage, currently 3MB useable until the Arduino core for ESP is updated.

Hi. sorry I pre-emptively posted the post. But yes your suggestion is one of the options but the challenge is the header unless I can find the code in the core library that you are using. I have a couple of ESP based boards on the way.