Skip to content

Urequest.request is not handling urls properly #673

Open
@xITmasterx

Description

@xITmasterx

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions