Sending http request to enter data into a google spreadsheet

I’m trying to send a simple http request, see example‘pizza’

to enter data into a google spreadsheet following the code explained at

When I enter the request into a browser it writes the data into the google table. When doing so in code the server answers with a Bad request. Any ideas?

if (client.connect("", 80))
    client.println("POST /macros/s/--PUB-SCRIPT-ID--/exec?col1=23&col2=33  HTTP/1.1");
    client.println("Connection: close");

    while (client.available()) //Read what is returned from the server
        char c =;
        if (millis() - lastSync > 500) continue; //Read for maximum 500ms, then continue


Hi @Heavy,

Good question! There was a thread on this subject, and they came up with an example script that pulls data by running some javascript on Google Docs to pull data from the core:

(this script:

There have also been some good threads on sending http POST and GET requests, here’s my goofy http get wrapper with basic auth: – It’s possible your POST request is failing for a lack of cookies and auth headers, but I’m not super familiar with the security requirements of posting to Google Docs :slight_smile:


Thank you, David!

Let me clarify the background of my question: I would like to send the request every time the spark core receives a PULSE by a water meter.