How do you create MS Graph open extensions with the same id on multiple users?

寵の児 提交于 2019-12-25 16:44:33

问题


I'm trying to add some profile data onto users in my AAD tenant. Using Microsoft Graph, I can add a an open extension to one user.

URL (POST): https://graph.microsoft.com/v1.0/me/extensions

Body: {
    "@odata.type": "Microsoft.Graph.OpenTypeExtension",
    "extensionName": "mydev.profile",
    "value1": "1000",
    "value2": "3"
}

This works, and I can update it with

PATCH https://graph.microsoft.com/v1.0/me/extensions/mydev.profile

However, if I try to add the same extension to a different user, I get an error that says the id is already used.

Request (POST): https://graph.microsoft.com/v1.0/users/{object-id}/extensions

Body: {
    "@odata.type": "Microsoft.Graph.OpenTypeExtension",
    "extensionName": "mydev.profile",
    "value1": "1000",
    "value2": "3"
}

Response (409 Conflict): {
  "error": {
    "code": "Request_BadRequest",
    "message": "An extension already exists with given id.",
    "innerError": {
      "request-id": "27c9c777-d4ce-4466-adce-a18505fffb30",
      "date": "2017-05-23T14:43:17"
    }
  }
}

The documentation I'm reading doesn't say anything about the id having to be unique in any scope. Am I missing something?

(I've tried doing this through Microsoft Graph Explorer, and through Postman. Same result.)


回答1:


Thanks for reporting this. We'll be investigating this bug. We have a couple of things going on here. I don't think specifying the @odata.type in the request is required, but when you add it we set the id the same as the supplied extensionName. Secondly we also scope the id to be unique per tenant (at least for directory resources like user), which is wrong. I imagine that it makes more sense for this to be unique per object, especially if you are looking to filter on all users that have your extension's (common) id.

If you are looking to create multiple open extensions with the same extensionName, that is possible without specifying the @odata.type in the payload. When you do that we generate a unique id. Or you could specify a different open property to tag the extension name. The downside is that until we make a fix, you won't be able to perform the aforementioned filter.

I'll respond when we make some fixes to this.

Hope this helps,



来源:https://stackoverflow.com/questions/44138214/how-do-you-create-ms-graph-open-extensions-with-the-same-id-on-multiple-users

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