Using API to Create A Repo On Behalf of Someone

We need to create a repository using an existing repo template on behalf of a user. Is the /user/repos POST a right API ? We don’t see a field related with an existing template repo in its request body.

Update:

I just find this API /admin/users/{username}/repos POST for creating a repository on behalf of a user. I, however, still don’t see how that uses an existing repo.

I believe this was answered in discord, but for others searching for this topic you would use the standard repo template endpoint (check swagger for exact path), then you’d use sudo header to be able to act as someone else.

Thanks. You are right. This question has been answered on Discord.

Here are log messages of an API call:

On the Gitea:

2021/09/09 09:59:57 Started POST /api/v1/repos/my-admin/my-code-template/generate?sudo=user-123 for 127.0.0.1:53502
2021/09/09 09:59:57 Completed POST /api/v1/repos/my-admin/my-code-template/generate?sudo=user-123 404 Not Found in 3.983329ms

On a client:

2021-09-09 09:59:56.988 DEBUG 88445 --- [  XNIO-1 task-2] c.i.c.reposetup.web.rest.GiteaClient     : ::: generate repo with sudo: GenerateRepoOption{avatar=true, description='null', gitContent=true, gitHooks=true, labels=true, name='my-code-repo', owner='user-123', _private=false, topics=true, webhooks=true} with repo template: my-code-template of user: my-admin
2021-09-09 09:59:56.998 DEBUG 88445 --- [  XNIO-1 task-2] c.i.c.reposetup.web.rest.GiteaClient     : {"avatar":true,"git_content":true,"git_hooks":true,"labels":true,"name":"my-code-repo","owner":"user-123","private":false,"topics":true,"webhooks":true}
2021-09-09 09:59:57.009 ERROR 88445 --- [  XNIO-1 task-2] c.i.c.reposetup.web.rest.GiteaClient     : Response{protocol=http/1.1, code=404, message=Not Found, url=http://localhost:3000/api/v1/repos/my-admin/my-code-template/generate?sudo=user-123}
2021-09-09 09:59:57.009 ERROR 88445 --- [  XNIO-1 task-2] c.i.c.reposetup.web.rest.GiteaClient     : Not Found

The request is submitted by an admin user. And the template owner, template repo, the owner of the repo are all there.

Also, the same request without sudo can be invoked successfully either by the admin user to generate the repo for himself or by the new repo owner.

Any possible reasons for the “Not Found” error?