Skip to content Skip to sidebar Skip to footer

Unable To Deserialize To Object: Type, KeyError: ' Key: Int; Value: Str '

I am writing a python script to create a user in azure devops using the python client library for azure-devops-rest-api. I am using the add_user_entitlement() function of MemberEn

Solution 1:

The deserialization error says that python cannot deserialize the response got to an object of type UserEntitlementsPostResponse. This happens when the response is not the expected one.

I edited the add_user_entitlement() function of MemberEntitlementManagementClient class of the python client by adding a line to print the response of the POST request. The response was:

{'operationResult': {'isSuccess': False, 'errors': [{'key': 5032, 'value': 'Access Denied: This user needs the following permission(s) on the resource Users to perform this action: Add Users'}], 'userId': '261d25ad091b', 'result': None}, 'isSuccess': False, 'userEntitlement': None}

Obviously, this was not the expected result. And this cannot be converted to a UserEntitlementsPostResponse type object. Hence, the error occurred.

As the error suggests, after adding the user (who runs the script) to a group 'project collection administrators' in our azure devops organization, the script worked correctly.

This step was important as the microsoft documentation for azure devops REST API ( https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/add-organization-users?view=azure-devops#prerequisites ) says:

To access and manage users, you must have Azure DevOps project collection administrator or organization owner permissions.


Post a Comment for "Unable To Deserialize To Object: Type, KeyError: ' Key: Int; Value: Str '"