JIRA SOAP API : get the list of users

前端 未结 3 1763
萌比男神i
萌比男神i 2021-01-06 09:19

I\'m working on a tool in C# that interfaces the JIRA SOAP API. I have read the doc one can find here: http://docs.atlassian.com/software/jira/docs/api/rpc-jira-plugin/lates

3条回答
  •  灰色年华
    2021-01-06 09:40

    It's a bit counter-intuitive as there's no general "Get Users" type command, and you need to load a project and role object before you can ask the question.

    Here's the same basic implementation in PHP (since I just wrote it), but keying off the "Users" role rather than "Developers":

    $base_url = 'https://yourjira.domain.com';
    $wsdl = $base_url . '/rpc/soap/jirasoapservice-v2?wsdl';
    
    $username = 'username';
    $password = 'password';
    
    $client = new SoapClient($wsdl);
    
    try {
        $token = $client->login($username, $password);
    }
    catch (SoapFault $fault) {
        echo "Error logging in to JIRA";
        print_r($fault);
    }
    
    $code = 'MYPROJECT'
    
    $project = $client->getProjectByKey($token, $code); 
    
    $role = $client->getProjectRole($token, 10000); // 10000 is typically the "users" role
    
    $users = $client->getProjectRoleActors($token, $role, $project);
    
    print_r($users);
    

提交回复
热议问题