# GET request from HTTPS using ESP8266 not working

**URL:** <https://forum.arduino.cc/t/get-request-from-https-using-esp8266-not-working/880995>\
**Category:** Networking, Protocols, and Devices\
**Created:** [July 2, 2021, 4:23pm UTC](https://forum.arduino.cc/t/get-request-from-https-using-esp8266-not-working/880995 "2021-07-02T16:23:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![monomon](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@monomon](https://forum.arduino.cc/u/monomon)\
**Post date:** [July 2, 2021, 4:23pm UTC](https://forum.arduino.cc/t/get-request-from-https-using-esp8266-not-working/880995/1 "2021-07-02T16:23:57Z")

</div>

I'm trying to access the following website (public API for Binance): [https://api.binance.com/api/v3/ticker/price](https://api.binance.com/api/v3/ticker/price)

On any browser, without a specific query, it will display a list of crypto coins and their USD exchange rates. This is the list I would like to save for further processing and parsing.

Since this is an HTTP **S** , I'm setting the wificlient to insecure so won't authenticate against the website. I'm also assuming port 443 - which might be a source for error.

Obviously ssid + password are updated to my home wifi. The ESP8266 connects and does not write there is an HTTP error so I guess it does manage to log on but does not get the page I see on my browser but rather a blank page?

Here is my current code:

```cpp
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClient.h>

const char* ssid = "ssid";
const char* password = "password";
WiFiClientSecure client;
HTTPClient sender;

void setup() 
{
  Serial.begin(115200); // serial monitoring
  
  WiFi.begin(ssid, password);

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

  Serial.print("Connected to WIFI!");

  client.setInsecure();
  client.connect("https://api.binance.com/api/v3/ticker/price", 443);
  
  if (sender.begin(client, "https://api.binance.com/api/v3/ticker/price"))
  {
    int httpCode = sender.GET();

    if (httpCode > 0) 
    {
      if (httpCode == HTTP_CODE_OK) 
      {
        String payload = sender.getString();
        Serial.println("\nHTTP_CODE_OK");
        Serial.println(payload);
      }
      else
      {
        Serial.printf("HTTP-Error: ", sender.errorToString(httpCode).c_str());
      }
    }
  }
  else
  {
    Serial.printf("Other HTTP error");
    sender.end();
  }
}

void loop() 
{
  
}

```

---

<div class="post-metadata">

**Author:** ![J-M-L](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/j-m-l/32/766245_2.png) [@J-M-L](https://forum.arduino.cc/u/J-M-L)\
**Post date:** [July 2, 2021, 4:49pm UTC](https://forum.arduino.cc/t/get-request-from-https-using-esp8266-not-working/880995/2 "2021-07-02T16:49:33Z")

</div>

In a unix terminal, a

```
curl https://api.binance.com/api/v3/ticker/price
```

does return fine so you can safely assume it's port 443

try with

```cpp
client.connect("https://api.binance.com", 443);

```

instead of the full URL

---

<div class="post-metadata">

**Author:** ![monomon](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@monomon](https://forum.arduino.cc/u/monomon)\
**Post date:** [July 2, 2021, 6:13pm UTC](https://forum.arduino.cc/t/get-request-from-https-using-esp8266-not-working/880995/3 "2021-07-02T18:13:49Z")

</div>

Thanks. That works, but the data I'm interested in parsing is not located at that address, but in the address that I've posted originally. I'm not sure why using the 'full' URL does not return a response like it does when using this URL?

For example:

```cpp
client.setInsecure();
  client.connect("https://api.binance.com", 443);
  
  if (sender.begin(client, "https://api.binance.com/api/v1/ticker/price?symbol=LTCBTC"))

```

This returns something useful, however I would like to get the entire list as available when entering the original address I've posted. Not sure why this does not get returned.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [October 30, 2021, 6:13pm UTC](https://forum.arduino.cc/t/get-request-from-https-using-esp8266-not-working/880995/4 "2021-10-30T18:13:50Z")

</div>

Closed on October 30, 2021, 6:13pm UTC

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