Skip to content

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

@copdips

Description

@copdips

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:

return await self.request_adapter.send_async(request_info, application.Application, error_mapping)

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions