msgraph-sdk-python icon indicating copy to clipboard operation
msgraph-sdk-python copied to clipboard

Patch application to add new app_role throws ODataError `Request contains a property with duplicate values.`

Open copdips opened this issue 2 years ago • 2 comments

Hello,

I would like to add a new app_role called test to an app registration, I used following code, but got ODataError Request contains a property with duplicate values.:

from msgraph.generated.models.application import Application
from msgraph.generated.models.app_role import AppRole
from uuid import uuid4
# some other imports and client init ignored here, as not relevant

app_id = "an existing app id"
role_name = "test"
app_role = AppRole()
app_role.allowed_member_types = ["User", "Application"]
app_role.description = role_name
app_role.display_name = role_name
app_role.is_enabled = True
app_role.id = str(uuid4())
app_role.origin = "Application"
app_role.value = role_name
app = Application()
app.app_roles = [app_role]
# get() is OK
get_result = await client.applications.by_application_id(app_id).get()
# patch is KO
patch_result = await client.applications.by_application_id(app_id).patch(body=app)

The below command throws error: 'Request contains a property with duplicate values.' (code: DuplicateValue) after the internal command: https://github.com/microsoftgraph/msgraph-sdk-python/blob/33cb15a452bd92b85ae62faaecc879761586237f/msgraph/generated/applications/item/application_item_request_builder.py#L123

Could you please give a help to explain what are the duplicate values, I checked the model of app_role, it should be OK: https://github.com/microsoftgraph/msgraph-sdk-python/blob/main/msgraph/generated/models/app_role.py

copdips avatar Jun 15 '23 10:06 copdips

Thanks for raising this @copdips

Any chance you can confirm if this is still an issue in the latest version of the SDK?

andrueastman avatar Apr 12 '24 16:04 andrueastman

same issue

copdips avatar Apr 18 '24 21:04 copdips