HTTP error code 301

Hi, I am using the web client demo to send an HTTP GET request to a web server to read the data in json format. However the web server returns an error code 301 page moved error. How do I redirect my request to the new location?

You should read the 301 redirect. There is a "Location:" parameter returned with the 301 that tells you where to redirect. Sometimes, this redirects to a SSL page. If it does, the ethernet library is not capable of a SSL connection.

How do I go about redirecting the GET request? This is the sample piece of code I am using to send without redirects.

if(client2.connect(server2, 80))
  {
    Serial.println("connection success goog");
    // send the HTTP PUT request:
    client2.println("GET /feeds/cells/SPID/5/public/basic?range=D10 HTTP/1.1");
    client2.println("Host: spreadsheets.google.com");
    client2.println("Connection: close");
    client2.println();
  }

What is the message the server is returning when you try that request? It should have a "Location:" line there.

edit: The easiest way to do this is change your code to match the new redirect url shown in the "Location:" parameter. If the new redirect url requires SSL (https://) then you will not be able to redirect.

edit2: You can't redirect. It is trying to redirect you to a SSL page, and the library doesn't support SSL. I tried the domain name you used in Host, and this is what I got: 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: Thu, 26 May 2016 12:17:31 GMT Location: https://spreadsheets.google.com/ X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN X-XSS-Protection: 1; mode=block Server: GSE Accept-Ranges: none Vary: Accept-Encoding Connection: close

So how do I send a GET request with SSL using Arduino?

komalhm: So how do I send a GET request with SSL using Arduino?

Is there some part of "You can't" that is too hard for you to understand?

PaulS: Is there some part of "You can't" that is too hard for you to understand?

Yes the part where I can't send a SSL encrypted GET request using Arduino.

komalhm: Yes the part where I can't send a SSL encrypted GET request using Arduino.

You can't because the network libraries do not support Secure Socket Layer (SSL) encryption. Most Arduinos do not have the processor power or the memory to do the required processing. I'm not certain if the Yun has SSL capability.

The RPi has the capability. It has the speed and memory to do it.