General Discussions

 View Only
  • 1.  HRConnect/Admin - Is there an API to query User Data in Cayuse Admin?

    Posted 08-07-2023 23:23

    Hi All,

    I was wondering if there is an API to query User Data in Cayuse Admin?

    We're using the HRConnect API to load Units, Users, Roles and Internal Associations. But we'd like to be able to audit User-Role assignments and similar data, is there an API available to extract this information, especially as some data of this is managed manually by the operational team.

    Thanks



    ------------------------------
    William Clarke
    Programmer Analyst & Team Leader
    University of Southern Queensland
    ------------------------------


  • 2.  RE: HRConnect/Admin - Is there an API to query User Data in Cayuse Admin?

    Posted 08-08-2023 05:56

    Following



    ------------------------------
    Isabella Johnsen
    Associate Director- Research Systems
    University of Utah
    ------------------------------



  • 3.  RE: HRConnect/Admin - Is there an API to query User Data in Cayuse Admin?

    TEAM CAYUSE
    Posted 08-08-2023 11:27
    Edited by Simon Helton 08-08-2023 11:29

    Hi William and Isabella,

    Thanks for the question! I asked the folks in the know, since this is beyond my technical expertise, and this is what I was told:

    First, our public API is documented here: https://app.swaggerhub.com/apis/CayuseLLC/CayusePublicApi

    More specific to your question, we have retrieve roles for a user by user ID. You would first retrieve a list of users (so you'd have all users' IDs), then GET the roles for those users by ID.

    I hope this is helpful. Let me know if there's anything this doesn't cover!

    Simon



    ------------------------------
    Simon Helton
    He/him
    Community Manager
    Cayuse
    ------------------------------



  • 4.  RE: HRConnect/Admin - Is there an API to query User Data in Cayuse Admin?

    Posted 08-08-2023 13:51

    Thanks very much Simon, that sounds like it could cover what we need.



    ------------------------------
    William Clarke
    Programmer Analyst & Team Leader
    University of Southern Queensland
    ------------------------------



  • 5.  RE: HRConnect/Admin - Is there an API to query User Data in Cayuse Admin?

    Posted 08-08-2023 14:52

    I've written a very quick PHP script using that API and it appears to meet our needs:

    echo "Using Production environment.<br>".PHP_EOL;
    $sessionKey = CallSiginAPI(<OurURLandTenentID>);
    $domainURL = "https://developer.prod-au.cayuse.com/v1/"; 

    $authorization = "Authorization: Bearer ".$sessionKey;    

    $usersURL = $domainURL."users";
    $response = CallAPI("GET", $usersURL, $authorization);
    $decoded_json = json_decode($response, false);

    $totalPages = $decoded_json->page->totalPages;

        /* Get all pages */
        $usertext = "Username,Name,Roles".PHP_EOL;
        for ($currentPage = 0; $currentPage <= $totalPages; $currentPage++)
        {
           $response = CallAPI("GET", $usersURL."?page=".$currentPage, $authorization);
           $decoded_json = json_decode($response, true);
           $users = $decoded_json['users'];
           foreach($users as $user)
           {
               if ($user['active'] != 1)
               {
                 $usertext=$usertext.$user['username'].",".$user['firstName']." ".$user['lastName'].",";
                 $userid = $user['id'];
                 $response2 = CallAPI("GET", $usersURL."/".$userid."/"."roles", $authorization);
                 $decoded_roles_json = json_decode($response2, true);
                 $roles = $decoded_roles_json['user-group'];
                 foreach($roles as $role)
                 {
                   $usertext=$usertext.$role["groupGroupName"].",";
                 }
                 $usertext=$usertext.PHP_EOL;
               }
            }
        }
        file_put_contents($filename, $usertext);
        echo "Done.";



    ------------------------------
    William Clarke
    Programmer Analyst & Team Leader
    University of Southern Queensland
    ------------------------------