Sharp Cypher
Sharp Cypher

Reputation: 57

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

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.)

Upvotes: 1

Views: 569

Answers (1)

Dan Kershaw - MSFT
Dan Kershaw - MSFT

Reputation: 5838

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,

Upvotes: 1

Related Questions