Greetings,
I am trying to program a quick detection of a repository under a project and if that repo does not exist create it.
So, I use the API to check for its existence, and upon a 404 I create a POST (with pycurl) to
/rest/api/1.0/projects/PROJECT/repos/toplevel
Where toplevel is an existing repo.
The payload is:
{"name": "newrepo",
"scmID": "git",
"forkable": true}
I then POST this to
/rest/api/1.0/projects/PROJECT/repos/toplevel
Expecting a new repo in toplevel/newpo.
Instead, a new repo is created in my personal area:
(The POST shows me the location)
/rest/api/1.0/projects/~USERNAME/repos/newrepo
I don't understand the redirection.
I have attempted to use this documentation along with examples I've found in these forums.
https://docs.atlassian.com/bitbucket-server/rest/7.7.1/bitbucket-rest.html#idp173
Hi @jagauthier ,
please try to skip toplevel repository in both requests.
1) check, if repository newrepo exist
GET /rest/api/1.0/projects/PROJECT/repos/newrepo
2) if not, create new newrepo repository
POST /rest/api/1.0/projects/PROJECT/repos
with payload
{
"name": "My repo",
"scmId": "git",
"forkable": true
}
You also need to have PROJECT_ADMIN permission for the project PROJECT.
I see the issue. I was trying to create a repo inside a repo. Thanks for pointing it out!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.