Gitlab:通过API创建新用户 - 404

4

我正在尝试使用Gitlab API v3创建新用户。

Gitlab API文档:https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/users.md#user-creation

我发送POST请求到mygitlabhost/api/v3/users/,并提供所有必需的数据:email=losddsd@gmail.com&password=33wrwsdfsf3&username=testone&name=fuuu,但是返回了404错误。实际上,我可以通过GET请求对mygitlabhost/api/v3/users/列出所有用户,因此API似乎正在运行。

请求详细信息:http://imm.io/120o6

我错在哪里了?


这是一个类似的问题(https://github.com/gitlabhq/gitlabhq/issues/3411),但不适用于您的情况:您没有为您的GitLab服务器设置相对路径。 - VonC
请查看Gitlab的日志。 - Adrian
1个回答

1
请注意,问题3411 "无法将用户添加到团队"有一些解决方法:
  • Apache
    /etc/apache2/sites-available/default中添加以下内容:
  ProxyPass http://127.0.0.1:8085/gitlab/api
  ProxyPassReverse http://127.0.0.1:8085/gitlab/api

  • NGinX
location /api {
  proxy_set_header   X-Forwarded-Proto $scheme;
  proxy_set_header   Host              $http_host;
  proxy_set_header   X-Real-IP         $remote_addr;
  proxy_pass http://gitlab-sock/gitlab/api;
  proxy_redirect default;
}

要解决此问题,您可以修改文件:app/assets/javascripts/api.js.coffee以匹配您的设置。

在我们的情况下,路径前缀为gitlab:

users_path: "/gitlab/api/:version/users.json"
user_path: "/gitlab/api/:version/users/:id.json"
notes_path: "/gitlab/api/:version/projects/:id/notes.json"

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接