2014-09-29 84 views
0

我一直在玩一段時間的參數,但我仍然得到相同的422驗證錯誤。我正在使用runscope來測試我的webhooks是否工作。create_hook驗證錯誤422

url_path = "https://k1lavjuzlcvj.runscope.net" 

repo.create_hook(name="testhook",config={"url":url_path, "content_type":"json"}) 

這是我從這次通話

09-29 13:35 github3  DEBUG POST https://github.umn.edu/api/v3/repos/umn-csci-2041F14/testbalas/hooks with {"name": "testhook", "active": true, "config": {"content_type": "json", "url": "https://k1lavjuzlcvj.runscope.net"}, "events": ["push"]}, {} 
09-29 13:35 requests.packages.urllib3.connectionpool DEBUG "POST /api/v3/repos/umn-csci-2041F14/testbalas/hooks HTTP/1.1" 422 113 
09-29 13:35 logger  ERROR Failure while setting hook for testbalas: 
Traceback (most recent call last): 
    File "./createurlhooksbyuid", line 107, in <module> 
    repo.create_hook(name="testhook",config={"url":args.url, "content_type":"json"}) 
    File "/Users/nate/Git-Projects/administration/dependencies/github3.py/github3/decorators.py", line 38, in auth_wrapper 
    return func(self, *args, **kwargs) 
    File "/Users/nate/Git-Projects/administration/dependencies/github3.py/github3/repos/repo.py", line 613, in create_hook 
    json = self._json(self._post(url, data=data), 201) 
    File "/Users/nate/Git-Projects/administration/dependencies/github3.py/github3/models.py", line 100, in _json 
    if self._boolean(response, status_code, 404) and response.content: 
    File "/Users/nate/Git-Projects/administration/dependencies/github3.py/github3/models.py", line 121, in _boolean 
    raise GitHubError(response) 
github3.models.GitHubError: 422 Validation Failed 

任何幫助,將不勝感激收到堆輸出,謝謝!

回答

1

我剛剛有機會對此進行測試。如果您檢查從GitHub收到迴應,你會看到以下內容:

>>> e.response.json() 
{u'documentation_url': u'https://developer.github.com/v3/repos/hooks/#create-a-hook', u'message': u'Validation Failed', u'errors': [{u'field': u'name', u'code': u'invalid', u'resource': u'Hook', u'value': u'requestbin'}]} 

如果你再回頭看向documentation更加緊密,你會看到的例子掛鉤的名稱是「網絡」。當我將我的鉤子的名稱更改爲"web"時,鉤子創建工作。

要清楚,要解決這個問題改變你create_hook呼籲:

repo.create_hook(name="web",config={"url":url_path, "content_type":"json"}) 
+0

這是正確的,謝謝! – nbalas 2014-09-30 15:36:16

+0

不客氣!對不起,我沒有注意到它/在將它推到這裏之前對它進行了測試。對我來說應該是更明顯的了 – 2014-09-30 18:49:45