ThingHTTP

The ThingHTTP App allows a microcontroller or low-level device to connect to any web service using HTTP over a network or Internet. You create an HTTP object using the ThingHTTP App and then control the object with simple API commands. ThingHTTP supports GET, POST, PUT, and DELETE methods, SSL, Basic Authentication, custom hostname, custom headers, different content types, and the 1.0 and 1.1 versions of HTTP. With this app, you can have a device interface with many web services and APIs such as Prowl and Twilio without having to implementing the protocol on the device level.


Send Request

To perform your ThingHTTP request send an HTTP POST to https://api.thingspeak.com/apps/thinghttp/send_request and include your ThingHTTP API key and message.

Example POST:
POST https://api.thingspeak.com/apps/thinghttp/send_request
     api_key=XXXXXXXXXXXXXXXX
     message=hello world


Replacements

The ThingHTTP request can have placeholders for data to be replaced when the request is sent. To make a replacement, enclose the replacement name in %% signs in the ThingHTTP Body form field. An example Body field might look like:

from=thingspeak&message=%%message%%

Then, pass the replacement name in the API request as a parameter, without the enclosing %% signs. An example replacement appears in the example POST request above, with "message" equal to "hello world".

Channel Values

You can retrieve the last value from a Channel field by including the following in the ThingHTTP Body form field:

%%channel_CHANNEL_ID_field_FIELD_NUMBER%%

For example, to set the "message" parameter equal to the last value from Channel 1417, field 1:

message=%%channel_1417_field_1%%

Parse String

ThingHTTP sends back the full response that is generated by the request. If you are looking to extract a piece of data from the response, you can add a Parse String to the ThingHTTP Request. This feature allows you to do the parsing on the ThingSpeak side instead of wasting code space on the device / microcontroller side. The format is Parent_cell.child_cell etc. If you also know the full XPATH to the data, you can specify the XPATH as the Parse String.

Additionally, you can parse JSON data by using its JavaScript-equivalent dot notation. For example, if you are parsing https://graph.facebook.com/cocacola you can use a parse string of cover.cover_id to extract the value of the cover_id.


Tutorials