如何通过project.repos.create api创建git存储库



问题很简单,但我只会遇到错误:

POST https://sourcerepo.googleapis.com/v1/projects/<example>/repos?key={YOUR_API_KEY} 
{
 "name": ">repos>"
}

给出:

HTTP/400 
cache-control:  private
content-encoding:  gzip
content-length:  251
content-type:  application/json; charset=UTF-8
date:  Thu, 15 Feb 2018 22:46:47 GMT
server:  ESF
vary:  Origin, X-Origin, Referer
{
 "error": {
  "code": 400,
  "message": "Request contains an invalid argument.",
  "status": "INVALID_ARGUMENT",
  "details": [
   {
    "@type": "type.googleapis.com/google.rpc.LocalizedMessage",
    "locale": "en-US",
    "message": "Invalid repo name: repos. Must be of the form projects/<project>/repos/<repo>"
   }
  ]
 }
}

其中example是一个现有项目,而存储库是我要创建的存储库名称。

我想念什么?我未能找到工作代码的示例。

这是错误的最重要部分:

{
 ....
    "message": "Invalid repo name: repos. Must be of the form projects/<project>/repos/<repo>"
 ....
}

告诉您name字段的格式不正确。假设您有此设置:

project :your-project-name

repo :Desure-Repo-name

那么您的要求主体必须是:

{
  "name": "projects/your-project-name/repos/desired-repo-name"
}

执行后,您将收到确认:

200
cache-control:  private
content-encoding:  gzip
content-length:  77
content-type:  application/json; charset=UTF-8
date:  Wed, 21 Feb 2018 11:12:46 GMT
server:  ESF
vary:  Origin, X-Origin, Referer
{
 "name": "projects/your-project-name/repos/desired-repo-name"
}

相关内容

  • 没有找到相关文章

最新更新