SparkCore --> ThingSpeak - HTTP Get Problems | Particle / Spark | Forum

The ThingSpeak community site has been upgraded to a new site. This site is currently in read-only mode. You can ask questions or post and read discussions on the new site.

Please consider registering

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —

— Match —

— Forum Options —

Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
SparkCore --> ThingSpeak - HTTP Get Problems
No permission to create posts
February 13, 2015
3:04 am
New Member
Forum Posts: 2
Member Since:
February 13, 2015
sp_UserOfflineSmall Offline

Hi All,

I've recently purchased a couple of SparkCores that I want to communicate with each other via ThingSpeak.

I have one Core that is writing a value to a channel - all is good with this.

My other Core needs to read from that channel and then react. Should be simples, but my Core is not GETting the same data as my browser. I am using the ThingSpeak IP number to eliminate any potential DNS issues.

My channel field GET is:

This is currently resulting a simple "2" when requested via a browser (or POSTMAN) but on my Core the result is a 400:

Application>.Start of Loop.
HttpClient>.Connecting to IP:
HttpClient>.Start of HTTP Request.
GET channels/24587/field/1.json HTTP/1.0
Connection: close
Accept: */*
HttpClient>.End of HTTP Request.

HttpClient>.Receiving TCP transaction of 128 bytes.
HTTP/1.1 400 Bad Request
Server: nginx/1.7.5
Date: Mon, 09 Feb 2015 20:54:50 GMT
Content-Type: text/html
Content-Length: 172
Connection: close

400 Bad Request

400 Bad Request


HttpClient>.End of TCP transaction.
HttpClient>.Error: Timeout while reading response.

HttpClient>.End of HTTP Response (5423ms).
HttpClient>.Status Code: 400
----------------------------------Application>.Response status: 400
----------------------------------Application>.HTTP Response Body:
400 Bad Request

400 Bad Request



My SparkCore sketch uses the HttpClient from the Spark library:

// This #include statement was automatically added by the Spark IDE.
#include "HttpClient/HttpClient.h"

* Declaring the variables.
unsigned int nextTime = 0; // Next time to contact the server
HttpClient http;

// Headers currently need to be set at init, useful for API keys etc.
http_header_t headers[] = {
// { "Content-Type", "application/json" },
// { "Accept" , "application/json" },
{ "Accept" , "*/*"},
{ NULL, NULL } // NOTE: Always terminate headers will NULL

http_request_t request;
http_response_t response;

// thing speak api IP
IPAddress server(184,106,153,149);

void setup() {

void loop() {
if (nextTime > millis()) {

Serial.println("Application>\tStart of Loop.");
// Request path and body can be set at runtime or at setup.
request.ip = server;
//request.hostname = "";
request.port = 80;
//request.path = "channels/24587/fields/1/last";
request.path = "channels/24587/field/1.json";

// The library also supports sending a body with your request:
//request.body = "{\"key\":\"value\"}";

// Get request
http.get(request, response, headers);

Serial.print("Application>\tResponse status: ");

Serial.print("Application>\tHTTP Response Body: ");

nextTime = millis() + 10000;

I've been playing with this for a couple of weeks now trying to get a working solutio, but no dice.

Any help gratefully received.

February 13, 2015
3:59 pm
New Member
Forum Posts: 2
Member Since:
February 13, 2015
sp_UserOfflineSmall Offline

The problem has been found...
Missing "/" at the start of the path.

request.path = "/channels/24587/field/1.json";

Forum Timezone: America/New_York

Most Users Ever Online: 166

Currently Online:
25 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 272

Vinod: 240

piajola: 95

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 8665

Moderators: 1

Admins: 2

Forum Stats:

Groups: 3

Forums: 14

Topics: 1600

Posts: 5760

Newest Members:

techhhelp5, ken, tran, huldacormier, bogart, estebanmateo93

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457