如何使用 GitHub APIv3 进行源导入

How to do a source import with GitHub APIv3

背景: 我正在尝试构建一个将 public 存储库复制到登录帐户的应用程序。

现在我正在尝试在 PostMan 中进行源导入,并且我正在使用以下设置:

我向这个 link 发出 PUT 请求:

https://api.github.com/repos/{myusername}/{empty github repository}/import

与以下 header:

Accept:application/vnd.github.barred-rock-preview

有了这个body:

{
  "vcs": "git",
  "vcs_url": "https://github.com/{owner of repo i want to copy}/{repo i want to copy}",
  "vcs_username": "{myusername}",
  "vcs_password": "{mypassword}"
}

我已阅读github API for importing repositories。但我从服务器收到以下响应:

{
  "message": "Not Found",
  "documentation_url": 
  "https://developer.github.com/v3/migrations/source_imports/#start-an-import"
}

为什么服务器 return 未找到?我如何让它工作

需要Authentication否则会得到404 Not Found

使用用户名和密码进行身份验证

放URL:

https://{myusername}:{mypassword}@api.github.com/repos/{myusername}/{myreponame}/import

请求正文

{
  "vcs": "git",
  "vcs_url": "https://github.com/{ownerRepo}/{ownerRepoName}"
}

vcs_usernamevcs_password 用于远程回购,不是你的。