micropython / micropython/micropython-lib
Urequest.request is not handling urls properly
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 2.9k
- Forks
- 1.1k
- Ø Merge
- 7 T. 6 Std.
- Gemergte PRs (30 T.)
- 3
Beschreibung
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.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne bei dem im Issue gezeigten urequests.request-Aufruf und vergleiche die POST-Invocation mit der ausgegebenen Firestore-URL. Reproduziere die Anfrage gegen die bereitgestellte URL und stelle fest, ob das letzte Pfadsegment erhalten bleibt; abgeschlossen ist die Aufgabe, wenn die Anfrage das vorgesehene Firestore-Dokument ohne den gemeldeten malformed-parent-Fehler erreicht.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- api, networking
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 35/100