0

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

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现有项目在哪里,repos 是我要创建的存储库名称。

我错过了什么?我找不到工作代码的示例。

4

1 回答 1

1

这是错误中最重要的部分:

{
 ....
    "message": "Invalid repo name: repos. Must be of the form projects/<project>/repos/<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"
}
于 2018-02-21T11:22:32.157 回答