AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / coding / 问题

问题[microsoft-graph-api](coding)

Martin Hope
Bernietechy
Asked: 2025-04-06 21:22:07 +0800 CST

创建委托管理关系 POST 时如何在 Microsoft 图形 API 中找到统一角色的 roleDefinitionId

  • 6

我打算将 PHP CRM 与 Microsoft Graph 和合作伙伴中心集成,以便能够从 CRM 为我管理的客户创建委托管理员关系。这是一篇Microsoft 文章,其中演示了如何创建管理员关系对象。

我需要帮助来了解如何获取roleDefinitionId,specific administrative role in the tenant以便我可以将其传递到 POST 请求的正文中,或者如何列出unified roles并以编程方式获取roleDefinitionId。谢谢。

在 POST 请求主体中,我们可以看到roleDefinitionId和 ,它们required表示unified role正在请求。统一角色指的是正在请求的管理角色,例如等Global admin,User administrator例如来自客户租户的 。

在其 Microsoft POST 请求主体下方,我只是不知道他们如何知道“roleDefinitionIdin the body stands for which管理角色”

POST https://graph.microsoft.com/v1.0/tenantRelationships/delegatedAdminRelationships
Content-Type: application/json

{
  "displayName": "Contoso admin relationship",
  "duration": "P730D",
  "customer": {
    "tenantId": "4b827261-d21f-4aa9-b7db-7fa1f56fb163",
    "displayName": "Contoso subsidiary Inc"
  },
  "accessDetails": {
    "unifiedRoles": [
      {
        "roleDefinitionId": "29232cdf-9323-42fd-ade2-1d097af3e4de"
      },
      {
        "roleDefinitionId": "3a2c62db-5318-420d-8d74-23affee5d9d5"
      }
    ]
  },
  "autoExtendDuration": "P180D"
}

当然,在我的 HTML 表单中,我需要让用户根据名称(例如)选择管理角色global admin,然后后端能够将其转换为该角色,就像合作伙伴中心 GUI 的roleDefinitionId工作原理一样。目前,我需要在我的表单中输入……roleDefinitionId

我的设计流程 在此处输入图片描述

microsoft-graph-api
  • 1 个回答
  • 21 Views
Martin Hope
Oskar Persson
Asked: 2025-02-11 20:50:41 +0800 CST

无法使用 Graph API 更新 Microsoft Booking 中的 customQuestionAnswers

  • 5

我应该如何在 Microsoft Graph API 中更新预约中的 customQuestionAnswers?这是我尝试过的:

修补https://graph.microsoft.com/v1.0/solutions/bookingBusinesses/<businessId>/appointments/<appointmentId>

{
  "@odata.type": "#microsoft.graph.bookingAppointment",
  "customers": [
    {
      "@odata.type": "#microsoft.graph.bookingCustomerInformation",
      "customerId": "<my-customer-id>",
      "emailAddress": "[email protected]",
      "location": null,
      "name": "Test Testson",
      "notes": "",
      "phone": null,
      "timeZone": null,
      "customQuestionAnswers": [
        {
          "@odata.type": "microsoft.graph.bookingQuestionAnswer",
          "questionId": "9f66cb07-abbc-4427-b3ea-b6a4da80d10d",
          "isRequired": true,
          "selectedOptions": [
            "Video"
          ],
          "question": "Mötestyp",
          "answerOptions": [
            "Video",
            "Telefon"
          ],
          "answerInputType": "radioButton"
        }
      ]
    }
  ]
}

这会导致以下错误:

{
    "error": {
        "code": "UnknownError",
        "message": "",
        "innerError": {
            "date": "2025-02-11T12:40:27",
            "request-id": "f10492fe-93f6-42b7-8cc4-f675fa705e47",
            "client-request-id": "f713f76d-c962-a2e9-8694-7fafa2f83eb1"
        }
    }
}

删除 customQuestionAnswers 块可以“解决”该问题。

microsoft-graph-api
  • 1 个回答
  • 16 Views
Martin Hope
Mykl Sandusky
Asked: 2024-12-24 05:32:05 +0800 CST

使用 Graph API 分配应用保护策略时“无方法匹配路由模板”

  • 5

我的最终目标是使用 PowerShell 脚本创建应用保护并分配它。除了分配之外,一切都正常,因此我使用 Graph Explorer 来确定分配策略的正确语法。每个场景都失败,并显示“没有方法匹配路由模板”。权限已验证。策略和组 ID 已验证。欢迎任何帮助。

以下是带有分配的策略的响应预览。

    {
        "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#deviceAppManagement/androidManagedAppProtections('{ID}')/assignments",
        "value": [
            {
                "id": "cb16bf46-1479-45b2-8221-2f4c5cada212_incl",
                "target": {
                    "@odata.type": "#microsoft.graph.groupAssignmentTarget",
                    "groupId": "{ID}"
                }
            }
        ]
}

对于我想要分配的策略,GET 会检索正确的信息。目前没有分配。下面是一个例子。这是请求主体使用的每个语法的响应。尝试的不同选项在底部。

GET https://graph.microsoft.com/v1.0/deviceAppManagement/androidManagedAppProtections/{ID}/assignments/
Response Preview
{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#deviceAppManagement/androidManagedAppProtections('T_3cf871f9-9a39-46da-b776-1c5b2c13da48')/assignments",
    "@microsoft.graph.tips": "Use $select to choose only the properties your app needs, as this can lead to performance improvements. For example: GET deviceAppManagement/androidManagedAppProtections('<key>')/assignments?$select=target",
    "value": []
}

POST https://graph.microsoft.com/v1.0/deviceAppManagement/androidManagedAppProtections/{ID}/assignments/
Request Body
    {
        "target": {
            "@odata.type": "#microsoft.graph.groupAssignmentTarget",
            "groupId": "{ID}"
        }
    }
Response Preview
    {
         "error": {
         "code": "No method match route template",
         "message": "No OData route exists that match template ~/singleton/navigation/key/navigation with http verb POST for request /MAMAdmin_2412/MAMAdminFEService/deviceAppManagement/androidManagedAppProtections('{ID}')/assignments.",
          "innerError": {
              "date": "{DATE}",
              "request-id": "{ID}",
              "client-request-id": "{ID}"
            }
        }
    }

请求机构迄今已尝试过此。

#1
{
    "assignments": [
        {
            "target": {
                "@odata.type": "#microsoft.graph.groupAssignmentTarget",
                "groupId": "{ID}"
            }
        }
    ]
}

#2
{
    "assignments": [
        {
            "@odata.type": "#microsoft.graph.groupAssignmentTarget",
            "target": {
                "groupId": "{ID}"
            }
        }
    ]
}
#3
{
    "target": {
        "@odata.type": "#microsoft.graph.groupAssignmentTarget",
        "groupId": "{ID}"
    }
}
#4
{
    "@odata.type": "#microsoft.graph.groupAssignmentTarget",
    "target": {
        "groupId": "{ID}"
    }
}
#5
{
    "@odata.type": "#microsoft.graph.targetedManagedAppPolicyAssignment",
    "target": {
        "@odata.type": "#microsoft.graph.groupAssignmentTarget",
        "groupId": "{ID}"
    }
}
#6
{
    "assignments": [
        {
            "@odata.type": "#microsoft.graph.targetedManagedAppPolicyAssignment",
            "target": {
                "@odata.type": "#microsoft.graph.groupAssignmentTarget",
                "groupId": "{ID}"
            }
        }
    ]
}
#7
{
    "assignments": [
        {
            "@odata.type": "#microsoft.graph.deviceAndAppManagementAssignmentTarget",
            "target": {
                "@odata.type": "#microsoft.graph.groupAssignmentTarget",
                "groupId": "{ID}"
            }
        }
    ]
}
#8
{
    "@odata.type": "#microsoft.graph.deviceAndAppManagementAssignmentTarget",
    "target": {
        "@odata.type": "#microsoft.graph.groupAssignmentTarget",
        "groupId": "{ID}"
    }
}
#9
{
    "value": [
        {
            "@odata.type": "#microsoft.graph.deviceAndAppManagementAssignmentTarget",
            "target": {
                "@odata.type": "#microsoft.graph.groupAssignmentTarget",
                "groupId": "{ID}"
            }
        }
    ]
}
#10
{
    "value": [
        {
            "target": {
                "@odata.type": "#microsoft.graph.groupAssignmentTarget",
                "groupId": "{ID}"
            }
        }
    ]
}
microsoft-graph-api
  • 1 个回答
  • 20 Views
Martin Hope
JS Ares
Asked: 2024-12-17 02:59:58 +0800 CST

Outlook 事件组织者的电子邮件并不总是用户主体名称

  • 5

使用 Graph API,我们获取某个 Outlook 事件。该事件除其他详细信息外,还包含以下格式的组织者信息:

"organizer": {
  "emailAddress": {
    "address": "[email protected]",
    "name": "myroom"
  }
}

当我们尝试使用 Graph API 端点 /users/{id | userPrincipalName} 检索有关此用户的更多信息时,我们有时会遇到表明该用户不存在的响应。

在调查 Exchange Online (Office 365) 设置后,我们发现一些用户配置了别名或辅助/备用 SMTP 电子邮件地址,并且这些辅助地址包含在 Graph API 响应中的组织者的 emailAddress 对象中。这意味着事件数据中的地址字段可能引用这些辅助地址之一,而不是用户的主要电子邮件或用户主体名称 (UPN)。

问题:

有没有一种方法可以使用 /users Graph API 端点检索用户的信息,而不完全依赖于用户主体名称?或者,有没有一种方法可以使用用户的辅助电子邮件地址确定用户的用户主体名称或对象 ID?

限制: 我们无法修改 Exchange Online 设置,因为它们由我们的客户管理。

microsoft-graph-api
  • 1 个回答
  • 26 Views
Martin Hope
Tom
Asked: 2024-08-15 00:07:06 +0800 CST

无法正确验证 Microsoft Graph Java/Kotlin 客户端

  • 5

我有一个 bash 脚本,它使用 curl 和 Microsoft Graph API 来获取我想要的内容。但我无法使用 MS Java Graph Api SDK 将此脚本转换为 Kotlin 代码。

工作脚本是:

export CLIENT_ID='XXX' 
export CLIENT_SECRET='XXX' 
export TENANT_ID='XXX'
exoprt SCOPE='api://ourApp/2023/CustomScope'
export TOKEN=`curl \
    -d grant_type=client_credentials \
    -d client_id=$CLIENT_ID \
    -d client_secret=$CLIENT_SECRET \
    -d scope=$SCOPE \
    -d resource=https://graph.microsoft.com \
    https://login.microsoftonline.com/$TENANT_ID/oauth2/token \
    | jq -j .access_token`
curl -X GET \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    https://graph.microsoft.com/v1.0/servicePrincipals/XXX/appRoleAssignedTo \
    | jq .

我获得了应用程序的角色分配列表。(具有正确权限的 API 在该范围内公开)

现在我正尝试使用文档在 Kotlin 中重新创建它:https://learn.microsoft.com/en-us/graph/sdks/choose-authentication-providers ?tabs=csharp#client-credentials-provider

val clientSecretCredential = ClientSecretCredentialBuilder()
    .clientId(appId)
    .clientSecret(secret)
    .tenantId(tenantId)
    .build()

client = GraphServiceClient(
    clientSecretCredential,
    "api://ourApp/2023/CustomScope"
)

val result = client.servicePrincipals().byServicePrincipalId(appObjectId).get().appRoleAssignedTo

如果我使用此客户端发出请求,我会收到错误

com.microsoft.aad.msal4j.MsalServiceException: AADSTS1002012: The provided value for scope api://drupalwiki/2023/SyncEverything openid profile offline_access is not valid. Client credential flows must have a scope value with /.default suffixed to the resource identifier (application ID URI)

如果我使用“https://graph.microsoft.com/.default”作为范围,我只会得到一个空列表。我最终也无法将我们的范围重命名为例如“api://ourApp/2023/.default”,因为 Azure UI 说这个名称无效。除此之外,由于 bash 脚本有效,我只想以相同的方式初始化客户端,这可能吗?

非常感谢!

microsoft-graph-api
  • 1 个回答
  • 19 Views
Martin Hope
Jigyansu Nanda
Asked: 2024-08-05 13:02:33 +0800 CST

Microsoft GraphAPI 中的过滤器未按预期工作并产生奇怪的结果

  • 5

下面的查询应用了 timeOff 条目的过滤器,
sharedTimeOff/startDateTime >= formattedTodayDateTime并且
sharedTimeOff/endDateTime <= formattedRequiredEndDateTime

翻译过来就是formattedTodayDateTime <= timeOff's start_date and end_date <= formattedRequiredEndDateTime。

此查询给出响应中的条目数(非空)。

// headers and accessTokens approprately formed
params = Map();
params.put("$filter","sharedTimeOff/startDateTime ge " + formattedTodayDateTime + " and sharedTimeOff/endDateTime le " + formattedRequiredEndDateTime + "");
response = invokeurl
[
    url :graphUrl
    type :GET
    parameters:params
    headers:headers
];

在下面的查询中,我过滤了休假条目,例如,

formattedTodayDateTime <= timeOff's end_date <= formattedRequiredEndDateTime。

params = Map();
params.put("$filter","sharedTimeOff/endDateTime ge " + formattedTodayDateTime + " and sharedTimeOff/endDateTime le " + formattedRequiredEndDateTime + "");
response = invokeurl
[
    url :graphUrl
    type :GET
    parameters:params
    headers:headers
];

问题: 第二个查询应该给我更多的响应,但它却给了我完全空的响应。

我期望我的响应中包含更多条目。但总是得到空响应。
我尝试将查询更改为formattedTodayDateTime <= timeOff's end_date <= formattedRequiredEndDateTime,但这也得到了空响应。

microsoft-graph-api
  • 1 个回答
  • 18 Views
Martin Hope
Kuldeep Singh
Asked: 2023-08-19 21:50:43 +0800 CST

使用 Graph API 从 MS 学习资料中获取 Microsoft 认证列表

  • 5

我有一个 Microsoft learn 个人资料连接到我的个人 Microsoft 帐户。

在此输入图像描述

我正在尝试使用图形 API 从图形资源管理器获取认证列表。我已使用相同的 Microsoft 帐户登录到图形浏览器。

在此输入图像描述

我没有得到https://graph.microsoft.com/beta/me/profile/certificationsURL 的结果。我在这里缺少什么吗?

microsoft-graph-api
  • 1 个回答
  • 17 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    重新格式化数字,在固定位置插入分隔符

    • 6 个回答
  • Marko Smith

    为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会?

    • 2 个回答
  • Marko Smith

    VScode 自动卸载扩展的问题(Material 主题)

    • 2 个回答
  • Marko Smith

    Vue 3:创建时出错“预期标识符但发现‘导入’”[重复]

    • 1 个回答
  • Marko Smith

    具有指定基础类型但没有枚举器的“枚举类”的用途是什么?

    • 1 个回答
  • Marko Smith

    如何修复未手动导入的模块的 MODULE_NOT_FOUND 错误?

    • 6 个回答
  • Marko Smith

    `(表达式,左值) = 右值` 在 C 或 C++ 中是有效的赋值吗?为什么有些编译器会接受/拒绝它?

    • 3 个回答
  • Marko Smith

    在 C++ 中,一个不执行任何操作的空程序需要 204KB 的堆,但在 C 中则不需要

    • 1 个回答
  • Marko Smith

    PowerBI 目前与 BigQuery 不兼容:Simba 驱动程序与 Windows 更新有关

    • 2 个回答
  • Marko Smith

    AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String”

    • 1 个回答
  • Martin Hope
    Fantastic Mr Fox msvc std::vector 实现中仅不接受可复制类型 2025-04-23 06:40:49 +0800 CST
  • Martin Hope
    Howard Hinnant 使用 chrono 查找下一个工作日 2025-04-21 08:30:25 +0800 CST
  • Martin Hope
    Fedor 构造函数的成员初始化程序可以包含另一个成员的初始化吗? 2025-04-15 01:01:44 +0800 CST
  • Martin Hope
    Petr Filipský 为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会? 2025-03-23 21:39:40 +0800 CST
  • Martin Hope
    Catskul C++20 是否进行了更改,允许从已知绑定数组“type(&)[N]”转换为未知绑定数组“type(&)[]”? 2025-03-04 06:57:53 +0800 CST
  • Martin Hope
    Stefan Pochmann 为什么 {2,3,10} 和 {x,3,10} (x=2) 的顺序不同? 2025-01-13 23:24:07 +0800 CST
  • Martin Hope
    Chad Feller 在 5.2 版中,bash 条件语句中的 [[ .. ]] 中的分号现在是可选的吗? 2024-10-21 05:50:33 +0800 CST
  • Martin Hope
    Wrench 为什么双破折号 (--) 会导致此 MariaDB 子句评估为 true? 2024-05-05 13:37:20 +0800 CST
  • Martin Hope
    Waket Zheng 为什么 `dict(id=1, **{'id': 2})` 有时会引发 `KeyError: 'id'` 而不是 TypeError? 2024-05-04 14:19:19 +0800 CST
  • Martin Hope
    user924 AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String” 2024-03-20 03:12:31 +0800 CST

热门标签

python javascript c++ c# java typescript sql reactjs html

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve