Genesys Cloud - Developer Community!

 View Only

Sign Up

  • 1.  Issue with PatchUser method

    Posted 14 hours ago

    Using SDK PureCloud Platform.Client.V2 version 252.1.0, I am encountering an issue with the PatchUser method.  This application has been successful in adding users, stations, roles, etc. including updating the user's extension.  It seems somewhere around the end of 2025, it stopped working for extensions and does not generate errors. The same function works as expected when run on the developer web page.  In writing this, I found that the same thing is true for the EmployerInfo entries. The source code is at the bottom.

    *****This Body object submitted is 
    class UpdateUser {
      Id: 
      Name: 
      Chat: 
      Department: Access Nurse
      Email: 
      PrimaryContactInfo: 
      Addresses: System.Collections.Generic.List`1[PureCloudPlatform.Client.V2.Model.Contact]
      Title: Patient Coordinator
      Username: 
      PreferredName: 
      Manager: d66c15b9-f30a-4ad3-b0d5-c038efd2390d
      Images: 
      Version: 17
      ProfileSkills: 
      Locations: 
      Groups: 
      State: Active
      AcdAutoAnswer: False
      Certifications: 
      Biography: 
      EmployerInfo: class EmployerInfo {
      OfficialName: 
      EmployeeId: pludog
      EmployeeType: 
      DateHire: 
    }

      SelfUri: 
    }

    *****This body.Addresses.count submitted is 
    1

    *****This body.Addresses[0].Extension submitted is 
    6977

    *****The result object is 
    class User {
      Id: 9cb12a9a-fdc4-4196-88f7-328f565e0322
      Name: Pluto Dog
      Division: class Division {
      Id: 299b68dc-f47e-410a-a3ea-4f043010116a
      Name: Access Nurse
      SelfUri: /api/v2/authorization/divisions/299b68dc-f47e-410a-a3ea-4f043010116a
    }

      Chat: class Chat {
      JabberId: 6960198c875c752c9220a127@teamhealthinc.orgspan.com
    }

      Department: Access Nurse
      Email: pluto_dog@teamhealth.com
      PrimaryContactInfo: System.Collections.Generic.List`1[PureCloudPlatform.Client.V2.Model.Contact]
      Addresses: System.Collections.Generic.List`1[PureCloudPlatform.Client.V2.Model.Contact]
      State: Active
      Title: Patient Coordinator
      Username: pluto_dog@teamhealth.com
      Manager: class User {
      Id: d66c15b9-f30a-4ad3-b0d5-c038efd2390d
      Name: 
      Division: 
      Chat: 
      Department: 
      Email: 
      PrimaryContactInfo: 
      Addresses: 
      State: 
      Title: 
      Username: 
      Manager: 
      Images: 
      Version: 
      Certifications: 
      Biography: 
      EmployerInfo: 
      PreferredName: 
      RoutingStatus: 
      Presence: 
      IntegrationPresence: 
      ConversationSummary: 
      OutOfOffice: 
      Geolocation: 
      Station: 
      Authorization: 
      ProfileSkills: 
      Locations: 
      Groups: 
      Team: 
      WorkPlanBidRanks: 
      Skills: 
      Languages: 
      AcdAutoAnswer: 
      LanguagePreference: 
      LastTokenIssued: 
      DateLastLogin: 
      DateWelcomeSent: 
      SelfUri: /api/v2/users/d66c15b9-f30a-4ad3-b0d5-c038efd2390d
    }

      Images: 
      Version: 18
      Certifications: 
      Biography: 
      EmployerInfo: 
      PreferredName: 
      RoutingStatus: 
      Presence: 
      IntegrationPresence: 
      ConversationSummary: 
      OutOfOffice: 
      Geolocation: 
      Station: 
      Authorization: 
      ProfileSkills: 
      Locations: 
      Groups: 
      Team: 
      WorkPlanBidRanks: 
      Skills: 
      Languages: 
      AcdAutoAnswer: False
      LanguagePreference: 
      LastTokenIssued: 
      DateLastLogin: 
      DateWelcomeSent: 
      SelfUri: /api/v2/users/9cb12a9a-fdc4-4196-88f7-328f565e0322
    }

    *****The result.Addresses.Count array is 
    0

    ---------------------------

            public bool UpdateUserDetails(string userid, string department, string extension, string DID, string reportsTo, string skills, bool autoAnswer, string ADuserId, Int32 userVersion)
            {
                PureCloudRegionHosts region = PureCloudRegionHosts.us_east_1; // Genesys Cloud region
                Configuration.Default.ApiClient.setBasePath(region);
                var accessTokenInfo = PureCloudPlatform.Client.V2.Client.Configuration.Default.AuthTokenInfo.AccessToken = getGenesysTokenStringClientCredentials();
                if (uc.Find(u => u.UserId == userid).userState == "deleted")
                {
                    UpdateUsersDivision(userid);
                }
                var apiInstance = new UsersApi();
                var userId = userid;  
                var body = new UpdateUser(); 
                body.State = UpdateUser.StateEnum.Active;
                body.Department = department;
                body.Title = Title.Text;
                var addr = new List<Contact>();
                var contact = new Contact() { Extension = extension, Type = Contact.TypeEnum.Work, MediaType = Contact.MediaTypeEnum.Phone,  CountryCode = "US", Integration = "" };
                addr.Add(contact);
                if (DID.Length > 0)
                {
                    contact = new Contact() { Extension = "", Address = DID, Type = Contact.TypeEnum.Work2, MediaType = Contact.MediaTypeEnum.Phone };
                    addr.Add(contact);
                }
                body.Addresses = addr;
                body.Manager = reportsTo;
                body.AcdAutoAnswer = autoAnswer;
                EmployerInfo eInfo = new EmployerInfo() { EmployeeId = ADuserId };
                body.EmployerInfo = eInfo;
                MessageBox.Show($"Employee ID set to {ADuserId}");
                body.Version = userVersion;
                addStatusMessage($"*****This Body object submitted is {NL}" + body.ToString());
                addStatusMessage($"*****This body.Addresses.count submitted is {NL}" + body.Addresses.Count.ToString());
                addStatusMessage($"*****This body.Addresses[0].Extension submitted is {NL}" + body.Addresses[0].Extension.ToString());
                try
                {
                    var result = apiInstance.PatchUser(userId, body);
                    Debug.WriteLine(result);
                    addStatusMessage($"*****The result object is {NL}" + result.ToString());
                    addStatusMessage($"*****The result.Addresses.Count array is {NL}" + result.Addresses.Count.ToString());
                }
                catch (Exception e)
                {
                    addStatusMessage("Exception when calling Users.PatchUser: " + e.Message);
                }
                return true;
            }


    #API/Integrations

    ------------------------------
    Albert Smith
    Software Engineer
    ------------------------------


  • 2.  RE: Issue with PatchUser method

    Posted 14 hours ago

    Hello Albert, 

    Since this is dealing with the SDK and source code I am moving this over to the developer community. 

    But just taking a quick look over this the fact that it works in the developer web page but not in your application suggests that this is likely an SDK implementation issue rather than an API issue. 

    Some quick troubleshooting steps I would recommend:

    a. Enable debug logging for the SDK to see the actual API requests being made

    b. Compare the request payload between your application and the developer web page

    c. Try updating a single field at a time to isolate the issue

    d. Verify your authentication token has the necessary permissions for user updates

    I hope the developer community can have more info on whats going on.

    Cheers, 



    ------------------------------
    Cameron
    Online Community Manager/Moderator
    ------------------------------



  • 3.  RE: Issue with PatchUser method

    Posted 11 hours ago
    Edited by Jerome Saint-Marc 11 hours ago

    Hello,

    Can you share the current user info before running the request in API Explorer, and the request body and response after you try this from API Explorer? It would help.

    Doing a quick test via PI Explorer, it doesn't work for me - I mean it keeps the agent structure as is.

    The reason is that you are sending/setting the state attribute: body.State = UpdateUser.StateEnum.Active;

    Please try again removing this line/entry from your code.

    When state is provided, it is the only property taken into account. I know this was the case when changing state (going from active to inactive, ...).

    I have never tried with a user already in active state (and a request containing state=active). So I can't say if it was working differently or not.
    But that's probably the reason why your agent properties don't get updated.

    Also note that Employer Info is not rendered in the PatchUser response. To get EmployeerInfo, you need to do a GetUser with expand set to employerInfo.

    Regards,



    ------------------------------
    Jerome Saint-Marc
    Senior Development Support Engineer
    ------------------------------