无法在Gitlab服务器中使用API​​创建用户

时间:2017-03-27 10:29:45

标签: php git api gitlab

我正在使用gitlab PHP API并遵循此文档:https://docs.gitlab.com/ce/api/users.html#user-creation。当我尝试使用以下命令在Gitlab服务器中创建用户时,我收到错误:

curl --request POST --header "PRIVATE-TOKEN: MY-TOKEN" "http://myserver.com/api/v4/users?email=testemail@gmail.com&password=testPAssword&username=testuser&name=test&reset_password=true"

错误:

{"message":"500 Internal Server Error"}

但我可以创建项目和分支机构。

我的系统信息

System:     Ubuntu 16.04
Current User:   git
Using RVM:  no
Ruby Version:   2.3.3p222
Gem Version:    2.6.6
Bundler Version:1.13.7
Rake Version:   10.5.0
Redis Version:  3.2.5
Git Version:    2.10.2
Sidekiq Version:4.2.7

GitLab information
Version:    9.0.0
Revision:   cf020e6
Directory:  /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: postgresql
URL:        http://myServer.com
HTTP Clone URL: http://myServer.com/some-group/some-project.git
SSH Clone URL:  git@myServer.com:some-group/some-project.git
Using LDAP: no
Using Omniauth: no

GitLab Shell
Version:    5.0.0
Repository storage paths:
- default:  /var/opt/gitlab/git-data/repositories
Hooks:      /opt/gitlab/embedded/service/gitlab-shell/hooks/
Git:        /opt/gitlab/embedded/bin/git

我也为同一个创建了一个php脚本,但它也返回相同的错误。我的剧本是:

function fireCurl($url, $data = null){

            $content = json_encode($data);
            $curl = curl_init( $url);
            curl_setopt($curl, CURLOPT_HEADER, false);
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($curl, CURLOPT_HTTPHEADER, array("PRIVATE-TOKEN:". $this->token , "Content-type: application/json"));
            curl_setopt($curl, CURLOPT_POST, true);
            curl_setopt($curl, CURLOPT_POSTFIELDS, $content);
            $json_response = curl_exec($curl);
            $status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
            if ( $status != 200 ) {

                $Error = "Error: call to URL $url failed with status $status, response $json_response, curl_error " .curl_error($curl) . ", curl_errno " . curl_errno($curl);
                return $Error;
            }else{
                return $json_response;
            }
            curl_close($curl);
    }

请帮帮我

0 个答案:

没有答案