【问题标题】:How to pass # character for the $filter to Microsoft Graph?如何将 $filter 的 # 字符传递给 Microsoft Graph?
【发布时间】:2022-01-07 22:23:19
【问题描述】:

我尝试通过 userPrincipalName 使用 Microsoft Graph 过滤以下用户:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users",
    "value": [
        {
            "businessPhones": [],
            "displayName": "Champi Non Buen Dia",
            "givenName": "buendiachampi",
            "jobTitle": null,
            "mail": "champinon.buendia@champi.com",
            "mobilePhone": null,
            "officeLocation": null,
            "preferredLanguage": null,
            "surname": "urrutia",
            "userPrincipalName": "champinon.buendia_champi.com#EXT#@avtestonline.onmicrosoft.com",
            "id": "c6d071ee-5d89-49bb-ac23-768720e5eff4"
        }
    ]
}

当我使用以下 URL 请求时,我得到了上面的 JSON 结果:

https://graph.microsoft.com/v1.0/users?$filter=startswith(userPrincipalName,'champinon.buendia_champi.com')

,但是如果我添加到过滤器 #EXT# 我得到一个 bad request 结果,我怎样才能在过滤器值中传递该字符?

https://graph.microsoft.com/v1.0/users?$filter=startswith(userPrincipalName,'champinon.buendia_champi.com#EXT#')

我需要这样做的原因是,必须强制用户输入完整的用户名而不是其中的一部分,#EXT# 使过滤更准确,因为输入的用户名必须与 #EXT# 匹配。

【问题讨论】:

    标签: graph active-directory azure-active-directory microsoft-graph-api postman


    【解决方案1】:

    #EXT# 的值必须编码为 %23EXT%23 传递:

    https://graph.microsoft.com/v1.0/users?$filter=startswith(userPrincipalName,'edgardo.urrutia_tcs.com%23EXT%23@')
    

    【讨论】:

    • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
    猜你喜欢
    • 2017-01-24
    • 1970-01-01
    • 1970-01-01
    • 2013-10-10
    • 2017-10-16
    • 2016-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多