Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting bad request #8

Closed
hetkpatel opened this issue Dec 30, 2020 · 3 comments
Closed

Getting bad request #8

hetkpatel opened this issue Dec 30, 2020 · 3 comments

Comments

@hetkpatel
Copy link

hetkpatel commented Dec 30, 2020

Even after updating the firmware of my MKR1000, I get bad request as the errorReason(). Is there a way to get more detail on the errorReason() function; maybe an error code or solution?

@hetkpatel hetkpatel changed the title Getting Connection Lost Getting bad request Dec 30, 2020
@mobizt
Copy link
Owner

mobizt commented Dec 30, 2020

The bad request is from many reasons:

  • FIREBASE_HOST is not valid. Check it should not end with / and should not start with http://
  • FIREBASE_AUTH is not valid.
  • You set or push the JSON serialized string which contains some invalid tokens or invalid characters that cause the invalid JSON.
  • The node path parameter contains invalid tokens or empty.

The above list is total possible reasons of this error.

It's better to post the code here to check.

@mobizt mobizt closed this as completed Dec 30, 2020
@hetkpatel
Copy link
Author

Yea, here's the code:

#include "Firebase_Arduino_WiFi101.h"

FirebaseData firebaseData;

void setup() {
    Serial.begin(115200);
    delay(30000);
    Serial.println("Starting program");
    int status = WL_IDLE_STATUS;
    while (status != WL_CONNECTED){
        status = WiFi.begin(WIFI_SSID, WIFI_PASS);
        delay(300);
    }
    Firebase.begin(FIREBASE_URL, FIREBASE_TOKEN, WIFI_SSID, WIFI_PASS);

    String firstName;
    if (Firebase.getString(firebaseData, "firstName")) {
        firstName = firebaseData.stringData();
        Serial.println(firstName);
    } else {
        Serial.println(firebaseData.errorReason());
    }
}

void loop() {}

Things I've check so far:

  1. FIREBASE_URL starts with https and does not include a trailing /
  2. I assume FIREBASE_AUTH is my FIREBASE_TOKEN which is valid.
  3. I've tried connecting it to other WiFi sources like my phone's hotspot but still returns the same error.

@hetkpatel
Copy link
Author

Solved it! Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants