question

JessieYuan-MSFT avatar image
0 Votes"
JessieYuan-MSFT asked Jerryzy published

Customers User PATCH response returns 200 but not updating User Info

I am working on a script to update passwords for our customers users and ran into some weird behavior with the Partner Center API returning successfully but isn't actually updating anything. So I started trying other calls and it seems like I can Read everything but anything I try to Write to the partner center isn't working and I'm not receiving any errors and am getting a 200 response code.

I am a Global Admin in my organization, I have a registered Web App in the Partner Center and my App Registration in the Azure Portal has every permission granted for Partner Center API, Microsoft Graph, Windows Azure Active Directory and Microsoft Partner Center.

I can successfully get my access token and use it for any GET request I've tried. Below is the set up I am using in Postman to retrieve my access token(I've whited out the confidential values). The photo below that, is the response headers(minus the access token).

alt text

alt text

I can successfully use my bearer token for GET calls such as:
*"https://api.partnercenter.microsoft.com/v1/customers/"
"https://api.partnercenter.microsoft.com/v1/customers/{customer-tenant-id}"
"https://api.partnercenter.microsoft.com/v1/customers/{customer-tenant-id}/users"
"https://api.partnercenter.microsoft.com/v1/customers/{customer-tenant-id}/users/{user-id}"*

All of the above work great with no errors. But then I try to PATCH one of our customers users using:
*"https://api.partnercenter.microsoft.com/v1/customers/{customer-tenant-id}/users/{user-id}"*

With a payload to just change the user's first name like this:
{
"firstName": "TestMatt",
"attributes": {
"objectType": "CustomerUser"
}
}

I get a 200 OK response back, with the user returned, but the firstName value hasn't been updated in the returned response or in the GUI. I created a test user with firstName "Test", to show the response I receive AFTER trying to PATCH with the above payload to change the firstName from "Test "to "TestMatt".

alt text

The behavior almost feels like Microsoft is accepting the PATCH but nothing is happening after and I don't get any error response or message to go off of.

I have been following these two guides to the letter:
https://docs.microsoft.com/en-us/partner-center/develop/update-user-accounts-for-a-customer
https://docs.microsoft.com/en-us/partner-center/develop/reset-user-password-for-a-customer

Also when I tried to do this a month ago with the same exact credentials to test it, it worked. I took a break from the project and came back to this behavior. I have also created a new App Registration in the Azure Portal, gave it all the permissions, and tried again from the start but experienced the same behavior.

Any ideas?

partner-center-api
1.png (14.7 KiB)
2.png (12.0 KiB)
3.png (41.6 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Jerryzy avatar image
0 Votes"
Jerryzy answered Jerryzy published

Hi,

Would suggest to do a test with Partner Center SDK C# code like below:

   protected override void RunScenario()
         {
             // get customer user Id.
             string selectedCustomerUserId = this.ObtainCustomerUserId("Enter the ID of the customer user to update details");
    
             // get customer Id of the entered customer user.
             string selectedCustomerId = this.ObtainCustomerId("Enter the ID of the corresponding customer to update customer user");
             var partnerOperations = this.Context.UserPartnerOperations;
    
             this.Context.ConsoleHelper.StartProgress("Getting customer user");
    
             // get customer user.
             var selectedCustomerUser = partnerOperations.Customers.ById(selectedCustomerId).Users.ById(selectedCustomerUserId).Get();
             this.Context.ConsoleHelper.StopProgress();
             this.Context.ConsoleHelper.WriteObject(selectedCustomerUser, "Selected customer User");
    
             this.Context.ConsoleHelper.StartProgress("Getting customer");
    
             // get customer.
             var selectedCustomer = partnerOperations.Customers.ById(selectedCustomerId).Get();
             this.Context.ConsoleHelper.StopProgress();
             this.Context.ConsoleHelper.WriteObject(selectedCustomer, "Selected Customer");
    
             var updatedCustomerUser = new CustomerUser()
             {
                 PasswordProfile = new PasswordProfile() { ForceChangePassword = true, Password = "Password!1" },
                 DisplayName = "Shubham Bharti",
                 FirstName = "Shubham",
                 LastName = "Bharti",
                 UsageLocation = "US",
                 UserPrincipalName = Guid.NewGuid().ToString("N") + "@" + selectedCustomer.CompanyProfile.Domain
             };
    
             this.Context.ConsoleHelper.StartProgress("Updating the customer user");
    
             // update customer user information
             var updatedCustomerUserInfo = partnerOperations.Customers.ById(selectedCustomerId).Users.ById(selectedCustomerUserId).Patch(updatedCustomerUser);
             this.Context.ConsoleHelper.StopProgress();
             this.Context.ConsoleHelper.WriteObject(updatedCustomerUserInfo, "Updated customer user information");
         }



And in the response and Dashboard UI, the customer user first name changed as expected:

alt text


alt text



282-1351023.png (25.6 KiB)
301-1351025.png (26.3 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.