0

The question is very simple but I’m only getting errors :

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

Which gives :

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>"
   }
  ]
 }
}

Where example is an existing project and repos is the repository name I want to create.

What am I missing ? I failed to find an example of working code.

user2284570
  • 2,891
  • 3
  • 26
  • 74

1 Answers1

1

This is the most important part of the error:

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

Which tells you that the format of the name field is not correct. Let's say you have this settings:

Project: your-project-name

Repo: desired-repo-name

Then your request body must be:

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

After executing you'll receive the confirmation:

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"
}
Victor M Perez
  • 2,185
  • 3
  • 19
  • 22