user27940: I am using ESP8266 programmed from Arduino to get data from the Google Youtube API. API, of course, works great in a browser using URL:
https://www.googleapis.com/youtube/v3/channels?part=statistics&id=CHANNEL-ID&key=GOOGLE-API-KEY

The problem is that "gooogleapis.com" is not the location where from I would receive the answer to my HTTPS request, it comes from a different location. When above URL is entered, it is being redirected and request answer comes from another location.
So what happens on ESP8266 when I try to open that address(of course, with added proper channel ID and google key) is following:
HTTP/1.1 404 Not Found
Content-Type: text/html; charset=UTF-8
Content-Length: 1580
Date: Sun, 12 Mar 2017 14:40:18 GMT
Alt-Svc: quic=":443"; ma=2592000; v="36,35,34"
Connection: close

<!DOCTYPE html>
<html lang=en>
  <meta charset=utf-8>
  <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
  <title>Error 404 (Not Found)!!1</title>
  <style>
    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
  </style>
  <a href=//www.google.com/><span id=logo aria-label=Google></span></a>
  <p><b>404.</b> <ins>That’s an error.</ins>
  <p>The requested URL <code>/youtube/v3/channels</code> was not found on this server.  <ins>That���s all we know.</ins>
Done.

Which is the Google error page(you seen it!). This is my Arduino code:
#include "ESP8266WiFi.h"
#include <WiFiClientSecure.h>

const char* ssid     = "SSID";  // WiFi network name
const char* password = "pass"; // WiFi pass

const char* host = "googleapis.com"; // page I am trying to load
const char* fingerprint = "22 37 4D 58 43 F4 A1 24 12 71 2B 74 7A FC 36 FC 24 A0 F0 9D";

String ch_id = "CHANNEL ID";
String api_key = "API KEY";

void setup() {
  Serial.begin(115200); 
  delay(10);

  WiFi.begin(ssid, password); 

  while (WiFi.status() != WL_CONNECTED) { 
    delay(500);                        
    Serial.print(".");            
  }

  Serial.println("Connected to WiFi! Local IP address is: ");
  Serial.println(WiFi.localIP());

  WiFiClientSecure client; 
  if (!client.connect(host, 443))
  {
    Serial.println("I am unable to connect to that page."); 
    return; 
  }

  if (client.verify(fingerprint, host)) {
    Serial.println("certificate OK");
  } else {
    Serial.println("certificate NOT OK");
  }

  String url = "/youtube/v3/channels?part=statistics&id=" + ch_id + "&key=" + api_key;

  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
               "Host: " + host + "\r\n" +
               "Connection: close\r\n\r\n");
  delay(10);

  while (client.available()) {
    String linija = client.readStringUntil('\r'); 
    Serial.print(linija);
  }

  Serial.println("Done.");
}

void loop() { 
}


How to find out to which site I am redirected? 
How to read that from ESP8266 and redirect the same data to new site? 


user972: In your browser you used www.googleapis.com, but in your code you used googleapis.com.
https://googleapis.com/youtube/v3/channels?part=statistics&id=CHANNEL-ID&key=GOOGLE-API-KEY

returns a 404 page.
Add www. to your host in code.

27940: <p>I am using ESP8266 programmed from Arduino to get data from the Google Youtube API. API, of course, works great in a browser using URL:</p>

<pre><code>https://www.googleapis.com/youtube/v3/channels?part=statistics&amp;id=CHANNEL-ID&amp;key=GOOGLE-API-KEY
</code></pre>

<p>The problem is that "gooogleapis.com" is not the location where from I would receive the answer to my HTTPS request, it comes from a different location. When above URL is entered, it is being redirected and request answer comes from another location.</p>

<p>So what happens on ESP8266 when I try to open that address(of course, with added proper channel ID and google key) is following:</p>

<pre><code>HTTP/1.1 404 Not Found
Content-Type: text/html; charset=UTF-8
Content-Length: 1580
Date: Sun, 12 Mar 2017 14:40:18 GMT
Alt-Svc: quic=":443"; ma=2592000; v="36,35,34"
Connection: close

&lt;!DOCTYPE html&gt;
&lt;html lang=en&gt;
  &lt;meta charset=utf-8&gt;
  &lt;meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width"&gt;
  &lt;title&gt;Error 404 (Not Found)!!1&lt;/title&gt;
  &lt;style&gt;
    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* &gt; body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
  &lt;/style&gt;
  &lt;a href=//www.google.com/&gt;&lt;span id=logo aria-label=Google&gt;&lt;/span&gt;&lt;/a&gt;
  &lt;p&gt;&lt;b&gt;404.&lt;/b&gt; &lt;ins&gt;That’s an error.&lt;/ins&gt;
  &lt;p&gt;The requested URL &lt;code&gt;/youtube/v3/channels&lt;/code&gt; was not found on this server.  &lt;ins&gt;That���s all we know.&lt;/ins&gt;
Done.
</code></pre>

<p>Which is the Google error page(you seen it!). This is my Arduino code:</p>

<pre><code>#include "ESP8266WiFi.h"
#include &lt;WiFiClientSecure.h&gt;

const char* ssid     = "SSID";  // WiFi network name
const char* password = "pass"; // WiFi pass

const char* host = "googleapis.com"; // page I am trying to load
const char* fingerprint = "22 37 4D 58 43 F4 A1 24 12 71 2B 74 7A FC 36 FC 24 A0 F0 9D";

String ch_id = "CHANNEL ID";
String api_key = "API KEY";

void setup() {
  Serial.begin(115200); 
  delay(10);

  WiFi.begin(ssid, password); 

  while (WiFi.status() != WL_CONNECTED) { 
    delay(500);                        
    Serial.print(".");            
  }

  Serial.println("Connected to WiFi! Local IP address is: ");
  Serial.println(WiFi.localIP());

  WiFiClientSecure client; 
  if (!client.connect(host, 443))
  {
    Serial.println("I am unable to connect to that page."); 
    return; 
  }

  if (client.verify(fingerprint, host)) {
    Serial.println("certificate OK");
  } else {
    Serial.println("certificate NOT OK");
  }

  String url = "/youtube/v3/channels?part=statistics&amp;id=" + ch_id + "&amp;key=" + api_key;

  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
               "Host: " + host + "\r\n" +
               "Connection: close\r\n\r\n");
  delay(10);

  while (client.available()) {
    String linija = client.readStringUntil('\r'); 
    Serial.print(linija);
  }

  Serial.println("Done.");
}

void loop() { 
}
</code></pre>

<ul>
<li>How to find out to which site I am redirected? </li>
<li>How to read that from ESP8266 and redirect the same data to new site? </li>
</ul>
 972: <p>In your browser you used <code>www.googleapis.com</code>, but in your code you used <code>googleapis.com</code>.</p>

<pre><code>https://googleapis.com/youtube/v3/channels?part=statistics&amp;id=CHANNEL-ID&amp;key=GOOGLE-API-KEY
</code></pre>

<p>returns a 404 page.</p>

<p>Add <code>www.</code> to your host in code.</p>
