Making HTTP request to Google Forms

I am getting a HTTP 301 error that makes no sense to me when I try to do a GET request. The reason it makes no sense is that the Location: piece in the response header is identical to the URL I am sending in the GET request.

Here is the code I am using:

 * Created by
 * This example code is in the public domain
 * Tutorial page:

#include <SPI.h>
#include <Ethernet.h>

// replace the MAC address below by the MAC address printed on a sticker on the Arduino Shield 2
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

EthernetClient client;

int    HTTP_PORT   = 80;
//char   HOST_NAME[] = "";
char HOST_NAME[] = "";
//String PATH_NAME   = "/trigger";
String PATH_NAME = "/forms/d/e/1FAIpQLSeGskK9trCex4EPtS99ZRlVyXKUhTugSQUhdw3-Ugkhr19awQ/formResponse";
//String queryString = "?value1=26&value2=70";;
String queryString = "?usp=pp_url&entry.879050922=FROMforum&submit=Submit";;

void setup() {

  // initialize the Ethernet shield using DHCP:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to obtaining an IP address using DHCP");

  // connect to web server on port 80:
  if(client.connect(HOST_NAME, HTTP_PORT)) {
    // if connected:
    Serial.println("Connected to server");
    // make a HTTP request:
    // send HTTP header
    client.println(HTTP_METHOD + " " + PATH_NAME + queryString + " HTTP/1.1");
    client.println("Host: " + String(HOST_NAME));
    client.println("Content-Type: application/x-www-form-urlencoded"); 
    client.println("Accept: */*");
    client.println("Connection: close");
    client.println(); // end HTTP header

    while(client.connected()) {
        // read an incoming byte from the server and print it to serial monitor:
        char c =;

    // the server's disconnected, stop the client:
  } else {// if not connected:
    Serial.println("connection failed");

void loop() {


And here is the output/response header as printed in the serial monitor:

Connected to server
HTTP/1.1 301 Moved Permanently
Content-Type: text/html; charset=UTF-8
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: Mon, 01 Jan 1990 00:00:00 GMT
Date: Sun, 11 Apr 2021 12:42:21 GMT
P3P: CP="This is not a P3P policy! See for more info."
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
Content-Security-Policy: frame-ancestors 'self'
X-XSS-Protection: 1; mode=block
Server: GSE
Set-Cookie: NID=213=QFR3lHYlQXXstJ24SJ6fQeUPCtXseIbclqRDsI8WbhZsVJ3zg57gTMY9OXdOJ10RIF74UqU2-GLhLQM_LKaGV5RaSLywwb7IgW4Vh07cS2V02Lgc7wRIbLdYIuqNqibn2oezDJ-hWMbEjCtcU8CnWhGbqmxOTJww__WbnFE353I; expires=Mon, 11-Oct-2021 12:42:21 GMT; path=/;; HttpOnly
Accept-Ranges: none
Vary: Accept-Encoding
Connection: close
Transfer-Encoding: chunked

<TITLE>Moved Permanently</TITLE>
<H1>Moved Permanently</H1>
The document has moved <A HREF=";entry.879050922=FROMARDUINOforsure&amp;submit=Submit">here</A>.

Clearly its connecting, I just don't understand why I am getting a 301 error but the Location is no different than what I put in the request.

I am using a mega2560 with a W5100 ethernet shield.

It has redirected your request to an HTTPS address. Can your mega2560 with a W5100 ethernet shield support an HTTPS connection ?

The output shows that you need to make an HTTPS request instead of HTTP.
The Official Ethernet library for Ethernet Shield 2 does not support HTTPS. You can see the list of shield/board support HTTPS in this Arduino - HTTPS request tutorial

Can I ask how or maybe why that is the case. When I do the request on say, it works whether I put https or http in the URL, and either one in the Raw option it says HTTP/1.1. I know nothing about http (if that wasn't obvious already), so I don't understand why it wouldn't work on arduino when it works on reqbin (with what seems to be http not https).

Maybe reqbin supports both HTTP and HTTPS

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.