gogs/go-gogs-client

Cannot create Webhook

costibleotu opened this issue · 1 comments

Hi,

I'm using Gogs Version: 0.10.34.0330 / 0.11 RC.

I'm trying to create a hook through the api, and I get this response:
[{"fieldNames":["Config"],"classification":"RequiredError","message":"Required"}]

My code is:

import requests

organization = 'test'
repo_name = 'test'
token = 'ac16d61127466efc3d316db76e68b7358c8075b4'

data = {
    "type": "gogs",
    "config": {
        "url": "http://192.168.201.1:8080/hook",
        "content_type": "json"
    },
    "events": [
        "create",
        "delete",
        "fork",
        "push",
        "issues",
        "issue_comment",
        "pull_request",
        "release",
    ],
    "active": True
}

url = "http://192.168.201.100:3000/api/v1/repos/{o}/{r}/hooks?token={t}".format(o=organization, r=repo_name, t=token)

session = requests.Session()
response = session.post(url, data=data)
print response.text

Apparently I was not setting the requests lib accordingly(I was using "data" parameter instead of "json" )