[英]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.