按照關於this的說明SO問題我能夠使用GitHub REST API和R包httr
和RCurl
爲我擁有的組織創建回購。現在,我遇到了使用API刪除回購的問題。使用REST API刪除R中的Github組織回購
我在GitHub上創建了一個OAuth應用程序,並讓應用程序訪問我的組織。然後我運行下面的代碼來創建delete_repo
作用域的標記。
library(httr)
library(RCurl)
# 1. Find OAuth settings for github:
# http://developer.github.com/v3/oauth/
oauth_endpoints("github")
# 2. Register an application at https://github.com/settings/applications
# Insert your values below - if secret is omitted, it will look it up in
# the GITHUB_CONSUMER_SECRET environmental variable.
#
# Use http://localhost:1410 as the callback url
myapp <- oauth_app("TestApp", "app-number","secret-number")
scope <- 'delete_repo'
# 3. Get OAuth credentials
github_token <- oauth2.0_token(oauth_endpoints("github"),scope=scope, myapp)
每GitHub的API第3版開發人員指南,網址create組織中的一個新的回購協議是
https://api.github.com/orgs/:org/repos
使用這個網址我能夠創建一個名爲我的組織的私人回購協議的可靠性「通過運行:
#Push repository to Github
url_c = "https://api.github.com/orgs/Reliability/repos"
data = list("name"= "newRepo", "private" = "true")
POST(url = url_c, body = data, config(token = github_token))
要delete回購,開發指南指出,URL應該是這樣的形式
DELETE repos/:owner/:repo
對於一個組織的回購協議,我理解,這個URL應該是
https://api.github.com/orgs/:org/repos/:owner/:repo
然而,當我運行下面的代碼,我得到沒有發現404
的響應。
# Delete repository from Github organization
url_d = "https://api.github.com/orgs/Reliability/repos/Auburngrads/newRepo"
DELETE(url = url_d, config(token = github_token))
我錯過了什麼?