如何在多个用户上创建具有相同ID的MS Graph开放扩展? [英] How do you create MS Graph open extensions with the same id on multiple users?

查看:63
本文介绍了如何在多个用户上创建具有相同ID的MS Graph开放扩展?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试向我的AAD租户中的用户添加一些个人资料数据.使用Microsoft Graph,我可以向一个用户添加一个开放扩展.

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"
}

这行得通,我可以用

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

但是,如果我尝试将相同的扩展名添加到其他用户,则会收到一条错误消息,提示该ID已被使用.

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"
    }
  }
}

我是阅读并没有说明id在任何范围内都必须是唯一的.我想念什么吗?

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

(我尝试通过Microsoft Graph Explorer和Postman进行此操作.结果相同.)

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

推荐答案

感谢举报.我们将调查此错误.我们这里发生了几件事.我认为不需要在请求中指定@odata.type,但是在添加它时,我们将id设置为与提供的extensionName相同.其次,我们还将id的范围限定为每个租户唯一(至少对于user这样的目录资源而言),这是错误的.我想这对于每个对象唯一来说更有意义,尤其是当您希望过滤具有扩展名(通用)ID的所有用户时.

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.

如果要使用相同的extensionName创建多个打开的扩展名,则可以在有效负载中不指定@odata.type的情况下实现.当您这样做时,我们会生成一个唯一的id.或者,您可以指定其他open属性来标记扩展名.缺点是,除非我们进行修复,否则您将无法执行上述过滤器.

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.

希望这会有所帮助

这篇关于如何在多个用户上创建具有相同ID的MS Graph开放扩展?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆