Skip to content

Urequest.request is not handling urls properly #673

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

Open
xITmasterx opened this issue May 31, 2023 · 1 comment
Open

Urequest.request is not handling urls properly #673

xITmasterx opened this issue May 31, 2023 · 1 comment

Comments

@xITmasterx
Copy link

xITmasterx commented May 31, 2023

I was supposed to post the changes made for my entry in the database in Firestore, when this error popped up:


{
 "error": {
   "code": 400,
   "message": "Document parent name \"projects/vendo-app-979f8/databases/(default)/documents/products\" lacks \"/\" at index 63.",
   "status": "INVALID_ARGUMENT"
  }
}

I tracked the error down and printed the final path before being sent to Firestore. Here's the code used to send, as well as the link that was being sent using urequest.request:


def send_request(path, method="GET", params=dict(), data=None, dump=True):
    headers = {}
    if FIREBASE_GLOBAL_VAR.ACCESS_TOKEN:
        headers["Authorization"] = "Bearer " + FIREBASE_GLOBAL_VAR.ACCESS_TOKEN
    if method == "POST":
        print(path)
        response = urequests.request(method, path, data=None, json=data)
    else:
        response = urequests.request(method, path, headers=headers)
    if dump == True:
        if response.status_code < 200 or response.status_code > 299:
            print(response.text)
            raise FirestoreException(response.reason, response.status_code)
        jsonResponse = response.json()
        if jsonResponse.get("error"):
            error = json["error"]
            code = error["code"]
            message = error["message"]
            raise FirestoreException(message, code)
        return jsonResponse

And the path printed:
https://firestore.googleapis.com/v1/projects/vendo-app-979f8/databases/(default)/documents/products/001

why won't urequest recognize the last part of the url? And is there a fix to it?

Thanks for the help in advance.

@massimosala
Copy link

Hi

What do you mean by "recognize the last part of the url" ?

There isn't the query separator (character ?), so the full URL
https://firestore.googleapis.com/v1/projects/vendo-app-979f8/databases/(default)/documents/products/001
is sent AS-IS to the server.

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