fastai / ghapi

A delightful and complete interface to GitHub's amazing API
https://ghapi.fast.ai/
Apache License 2.0
610 stars 63 forks source link

Remove need to URL-quote some parameters #54

Closed choldgraf closed 3 years ago

choldgraf commented 3 years ago

I just found a gotcha where I was trying to update a github label that had a space in it. Trying to do so was raising a 400 error. I fixed it by doing:

from urllib.parse import quote
quote(label["name"])

It would be helpful to either automate this under-the-hood, or to raise a more helpful error that suggests this might be the issue.

hamelsmu commented 3 years ago

Do you mind sharing the full code of what you were trying to do with an example of what failed? This would help greatly! I can then use this directly in the docs!

choldgraf commented 3 years ago

Sure - for example, let's say I wanted to update this label:

https://github.com/jupyterhub/nativeauthenticator/labels/help%20wanted

to help-wanted (instead of help wanted)

if I ran:

api.issues.update_label("jupyterhub", "nativeauthenticator", "help wanted", "help-wanted")

I get

HTTP400BadRequestError: HTTP Error 400: Bad Request

if instead I run

api.issues.update_label("jupyterhub", "nativeauthenticator", quote("help wanted"), "help-wanted")

then it works

choldgraf commented 3 years ago

This doesn't always happen for things that have spaces in them (e.g., I am able to set labels on issues with spaces in them without escaping them), but for some reason the error pops up sometimes

jph00 commented 3 years ago

Thanks for the report @choldgraf . I've just pushed a update so you now don't need to URL-quote some parameters.