Uploading Arduino data to Google drive

Hello!
I want to upload sensor data from the Arduino Uno R3 to a Google Docs spreadsheet froma Google Docs form. For this, I need to make an HTTP POST request using the following URL:

https://docs.google.com/forms/d/****************************-***************/formResponse?ifq&entry.********=Night&entry.********=30&entry.********=27&submit=Submit

(**** represent formkey and entry numbers)

When I type this URL in my browser, an entry is added into the spreadsheet successfully. So I guess, there is no problem with the URL as such. There could be a problem in the Arduino code I am using for this URL. I am getting a HTTP/1.0 400 Bad Request error.

Any help would be appreciated. The code is as follows:

Code:
#include <SPI.h>
#include <Dhcp.h>
#include <Dns.h>
#include <Ethernet.h>
#include <EthernetClient.h>
#include <EthernetServer.h>
#include <EthernetUdp.h>
#include <Pstring.h>
#include <stdlib.h>

byte mac[] = { 0x**,0x**,0x**,0x**,0x**,0x**}; //Ethernet shield MAC
IPAddress server(74,125,232,128);// Make it char server[]= "www.google.com" if DNS is available
IPAddress ip = (,,,); //IP address to be added
IPAddress subnet = (,,,); //Subnet Mask to be added
IPAddress gateway = (,,,); //Gateway to be added
IPAddress DNS = (,,,); //DNS to be added

EthernetClient client;

void setup()
{
Serial.begin(9600);
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
// try to congifure using IP address instead of DHCP:
Ethernet.begin(mac, ip,gateway,subnet);//Make it Ethernet.begin(mac,ip,DNS,gateway,subnet); if DNS is available
}
delay(1000);
Serial.println("connecting...");

String data;
data+="";
data+="entry.=Night&entry.=30&entry.********=27&submit=Submit";

if (client.connect(server,80)) {
Serial.println("connected");

client.print("POST /forms/d/*************-/formResponse?ifq HTTP/1.0");
client.println("Host: docs.google.com");
client.println("User-Agent: Arduino/1.0");
client.println("Content-Type: application/x-www-form-urlencoded");
client.println("Connection: close");
client.print("Content-Length: ");
client.println(data.length());
client.println();
client.print(data);
client.println();

Serial.print("forms/d/*************-/formResponse?ifq HTTP/1.0");
Serial.println("Host: docs.google.com");
Serial.println("User-Agent: Arduino/1.0");
Serial.println("Content-Type: application/x-www-form-urlencoded");
Serial.println("Connection: close");
Serial.print("Content-Length: ");
Serial.println(data.length());
Serial.println();
Serial.print(data);
Serial.println();
}

}
void loop()
{
if (client.available()) {
char c = client.read();
Serial.print(c);
}

if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
}

delay(1000);
}

Hello

I'm trying to do something similar. Did you manage to solve your problem?

Cheers

Rob

If the submission works in your browser it may be simpler to use a GET request

    client.print("GET/formResponse?ifq&entry.********=Night&entry.********=30&entry.********=27&submit=Submit  HTTP/1.1");
    client.println("Host: docs.google.com");
    client.println("User-Agent: Arduino/1.0");
    client.println("Connection: close");
    client.println();

If you want to stick to POST, possible issues are (at a guess) your data.length() isnt returning the correct number of bytes, or it could be that you should be using POST ... HTTP/1.1 (not 1.0) as Connection: close was defined in 1.1. Possibly remove the User-Agent header, maybe google doenst like it..

Might also be that https:// is a problem. Last time I checked arduino library's didnt have the crypto required to do SSL.

It would be worth checking that plain old http:// works OK in your browser and doesnt get redirected automatically to the https:// version.

I have the same problem... solve it?

If https is indeed the issue here, you can create an app in google appengine, send your http request to the app and have it forward the request to your intended url.

Can you say me how?can you help me?

I find ithttps://cloud.google.com/appengine/docs/java/modules/routing