Closed
Description
Description of the problem, including code/CLI snippet
When trying to create webhooks on a repository with invalid URLs (like 127.x.x.x), GitLab returns HTTP 422 with a JSON body : {"error":"Invalid url given"}
. Under Python 3, the GitlabCreateError does not convert from bytes to str :
from gitlab import Gitlab
from gitlab.exceptions import GitlabCreateError
gl = Gitlab('https://gitlab.com', oauth_token="<TOKEN>")
project = gl.projects.get('<PROJECT>')
try:
project.webhooks.create({'url': 'http://127.0.0.1/'})
except GitlabCreateError as e:
print(str(e))
Expected Behavior
Under both Python 2 and 3, the above snippet should print
422: {"error": "Invalid url given"}
Actual Behavior
Under Python 2, it works as expected. Under Python 3 only, this prints
422: b'{"error": "Invalid url given"}'
Specifications
- python-gitlab version: 1.5.1
- API version you are using (v3/v4): v4
- Gitlab server version (or gitlab.com): GitLab.com (11.4.0-rc7-ee)
Metadata
Metadata
Assignees
Labels
No labels