Can't create a schema extension

扶醉桌前 提交于 2021-01-29 15:41:29

问题


I am trying to create a schema extension in Microsoft Graph API.

But it has failed with error message "Property type is invalid for target types".

POST https://graph.microsoft.com/v1.0/schemaExtensions
Content-type: application/json

{
    "id":"extendedData",
    "description": "Graph Learn training courses extensions",
    "targetTypes": [
        "Event"
    ],
    "properties": [
        {
            "name": "courseId",
            "type": "Integer"
        },
        {
            "name": "materialId",
            "type": "Integer"
        },
        {
            "name": "courseType",
            "type": "String"
        }
    ]
}

Response

{
    "error": {
        "code": "BadRequest",
        "message": "Property type is invalid for target types.",
        "innerError": {
            "date": ...,
            "request-id": ...,
            "client-request-id": ...
        }
    }
}

Why can't I create a schema extension and what error means?


回答1:


Integer type in properties is not supported for Event targetTypes based on Supported property data types.

You could change them to String.

Please note that you may will encounter a new error: Attempt to update complex extension definition on application: dexxxxx5-d9f9-48b1-a8ad-b7xxxxx25064 belonging to different context.

If you get this error, it means you still need to put an owner property in the JSON payload. (If you don't get this error, it's unnecessary to put owner property)

Register an Azure AD app and put the application id as the owner.

POST https://graph.microsoft.com/v1.0/schemaExtensions
Content-type: application/json

{
    "id":"extendedData",
    "description": "Graph Learn training courses extensions",
    "targetTypes": [
        "Event"
    ],
    "owner": "{application id of an Azure AD app}",
    "properties": [
        {
            "name": "courseId",
            "type": "String"
        },
        {
            "name": "materialId",
            "type": "String"
        },
        {
            "name": "courseType",
            "type": "String"
        }
    ]
}


来源:https://stackoverflow.com/questions/65603715/cant-create-a-schema-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!