简体   繁体   English

Microsoft Graph 更新 App Registration Approles API 补丁方法总是返回无法读取 JSON 请求负载

[英]Update App Registration Approles by Microsoft Graph API Patch method returns always Unable to read JSON request payload

On a App Registration I want to remove the App Roles by first disable the active ones and afterwards removing them.在应用程序注册中,我想通过首先禁用活动角色然后删除它们来删除应用程序角色。 I checked the commands by the developer tools what is executed and I come to the following request:我通过开发人员工具检查了执行的命令,并提出以下请求:

$graphApiUrl = 'https://graph.microsoft.com/v1.0/applications'+'/'+$apiAppReg.appId
$body = '{"appRoles":[{"description":"Applications can read","displayName":"Reader","id":"xxxxxxx-xxxx-xxxx-xxxx-xxxxxx","isEnabled":false,"value":"Read","allowedMemberTypes":["Application"]}]}
'

az rest --method PATCH --url $graphApiUrl --headers 'Content-Type=application/json' --body '$body'

I tried this in all orders, but it seems that this is resulting in an error.我在所有订单中都尝试过此操作,但这似乎导致了错误。

btw.顺便提一句。 the boby is copy from the request from the azure website男孩是从 azure 网站的请求中复制的

After reproducing from my end, I could able to achieve your requirement using PowerShell. To Disable the App Role I have set IsEnabled=$false for each app role in my Application.从我这边复制后,我可以使用 PowerShell 满足您的要求。要禁用应用程序角色,我已经为我的应用程序中的每个应用程序角色设置IsEnabled=$false

Below is the script that worked for me to disable the app role.下面是对我有用的脚本来禁用应用程序角色。

$App = Get-AzureADApplication -Filter "appId eq '$appId'"
$AppRoles = $app.AppRoles
for($I=0;$I -lt $AppRoles.Count;$I++)
{
    $app.AppRoles[$I].IsEnabled=$false
    Set-AzureADApplication -ObjectId $app.ObjectId -AppRoles $AppRoles
}

在此处输入图像描述

To Remove the app roles from the application I have used $AppRoles.Remove($AppRoles[$I]) .要从应用程序中删除应用程序角色,我使用$AppRoles.Remove($AppRoles[$I]) Below is the complete code that worked to delete the app roles from my Application.下面是用于从我的应用程序中删除应用程序角色的完整代码。

for($I=0;$I -lt $AppRoles.Count;$I++)
{
    $AppRoles.Remove($AppRoles[$I])
    Set-AzureADApplication -ObjectId $app.ObjectId -AppRoles $AppRoles
}

Below is the complete working code下面是完整的工作代码

Connect-AzureAD

$AppId = "<APPLICATION_ID>"
$ObjectId = "<OBJECT_ID>"

$App = Get-AzureADApplication -Filter "appId eq '$appId'"
$AppRoles = $app.AppRoles
for($I=0;$I -lt $AppRoles.Count;$I++)
{
    $app.AppRoles[$I].IsEnabled=$false
    Set-AzureADApplication -ObjectId $app.ObjectId -AppRoles $AppRoles
}

for($I=0;$I -lt $AppRoles.Count;$I++)
{
    $AppRoles.Remove($AppRoles[$I])
    Set-AzureADApplication -ObjectId $app.ObjectId -AppRoles $AppRoles
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 JSON 补丁 HTTP 从客户端到 API 的请求(在 AWS 上发布)返回“StatusCode:405,ReasonPhrase:'Method Not Allowed'” - JSON Patch HTTP request from client to API (published on AWS) returns "StatusCode: 405, ReasonPhrase: 'Method Not Allowed'" 无法在 Azure 应用注册中添加 Microsoft Service Bus API - Unable to add Microsoft Service Bus API in Azure App Registration 尝试通过调用 Microsoft Graph API - /applications 将 Azure 虚拟桌面 RBAC 中定义的委派权限范围添加到 AAD 应用程序注册 - Trying to add delegated permission scopes defined in Azure Virtual Desktop RBAC to AAD App registration by calling Microsoft Graph API - /applications 使用具有 Sites.Read.All 权限的托管标识向 Microsoft Graph Search API 发出 POST 请求时出现 401 Unauthorized - 401 Unauthorized when making a POST request to Microsoft Graph Search API using managed identity with Sites.Read.All permission Microsoft Graph Api User.Read.All 未授予我的域 - Microsoft Graph Api User.Read.All Not granted for my domain 如何在没有企业应用程序客户端密钥的情况下刷新 Microsoft Graph API 的令牌? - How to refresh the token of Microsoft Graph API without Client Secret for an Enterprise App? Microsoft Graph API 应用程序 Collections - Microsoft Graph API Application Collections Azure 应用程序服务上的守护进程 OWASP ZAP 始终返回代码 400 - 错误请求 - Daemon OWASP ZAP on Azure App Service always returns code 400 - Bad Request Microsoft Graph API - 用户增量查询挑战 - Microsoft Graph API - User Delta Query Challenges 如何使用 Microsoft Graph 更新云用户的扩展属性 API - How do I update the extensionAttributes for a cloud user using Microsoft Graph API
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM