我正在尝试执行以下操作

IDirectoryObjectWithReferenceRequest request = graphServiceClient.directoryRoles(roleId).members("$ref").buildRequest();
DirectoryObject o = new DirectoryObject();
o.id = "someid";
request.post(null, o);


并得到400。需要传递的第二个参数对象是什么?需要传递的第一个参数是什么?文档声明作为主体通过:

{"@odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/{id}" }


另外,要发布的第一个参数有什么处理?如果成功,它将立即返回?这似乎是报告成功/失败的非常不寻常的方式。

最佳答案

事实证明,以上完全错误。这是应该完成的方式:

        DirectoryObject o = new DirectoryObject();
        o.id = objectId;
        requireDelegatedPermissions = true;
        IDirectoryObjectCollectionReferenceRequest request = graphServiceClient.directoryRoles(roleId).members().references().buildRequest();
        return request.post(o);

10-08 03:42