POST request from Spark Core with body more than 64 characters

I need to post data from the Spark Core to my server.

The body in the POST request is 200 characters long. As soon as the size of the body increases beyond 64 characters, the core flashes red (using httpclient library).

If the body is less than 64 characters, it works fine.

How can I send 200 characters body using http POST to my server?


Hi @pteja

I don’t see anything in @nmattisson 's lbrary that has a 64 character limit. His code either takes a char array you give it or uses a 1024 char buffer internally.

Maybe you could post some of the code here and we can help you debug?


Hi @pteja,

I think flashing red can mean out of memory, so it might be that you are using up to much RAM with your code.


Here is the code used:

#include "application.h"
#include "HttpClient.h"
#include "HttpClient.cpp"

unsigned int i = 0;
char message[60]; // With 60 it works!!! With 65 or more it does not work - red flashes!!!!

* Declaring the variables.
HttpClient http;

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

http_request_t request;
http_response_t response;


void setup() {
    // Request path and body can be set at runtime or at setup.
	request.hostname = "";
	request.port = 80;
	request.path = "/V1/rawdata";

void loop() {
    // Creating POST body here:
	sprintf(message, "[{\"startAt\":\"september\",\"sensor\":\"kingqwerty\"}]");
	request.body =  message;
    // POST request, response, headers);

	// Show what is posted on serial output



In this code, if the message exceeds 64 characters, the core flashes red.

@nmattisson - Yes, that could be a possibility. However, since the error (red flashes) occurs only when the value exceeds 64 characters, it is likely it is because of limit of number of characters rather than RAM.

@bko & @nmattisson:
Can you run this code on your core with message[200]?


I tried this with the message string at 100 bytes and 200 bytes and it ran for several minutes before I stopped it without errors. Maybe something in your environment around the core like routers etc. is different.

I also added this code so I could flash it over the air again:

void loop() {
    int pinValue = digitalRead(D0);
    if (pinValue == HIGH) {
        while(true) { SPARK_WLAN_Loop(); }


Thanks @bko & @nmattisson.

Here is another issue related to sending a POST request.

The response got back from the server is:

Changing the timeout value has no effect.

Any idea what could be causing this?

Also the core sometimes does not connect to the WiFi network at all and needs several attempts for it to connect. Is this reported elsewhere as well?


@pteja, it looks like your server doesn’t respond, or the response doesn’t reach the Spark. Are GET requests working fine?

When it comes to network stability the CC3000 from TI has unfortunately not been as good as one could expect. Problems connecting to certain networks, certain routers and IP ranges have been fairly commonplace and while the situation has improved a lot since the firmware update, it’s still isn’t great.

Hi @pteja!

I have the same Problem with more than 64 characters. is there any idea???


@SebastianT - this might help you:
On your server (assuming you have access to your own server running PHP), put this PHP file - this is an echo server - echoes back whatever it gets:

Compile and put this code on the core - you need to edit the application.cpp file to match the echo server host details:

Using this I was able to make sure that there is some limit but it is much more than 64 bits.