Update adminConsentRequestPolicy
-
Article
-
-
Namespace: microsoft.graph
Update the properties of an adminConsentRequestPolicy object.
Permissions
One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions.
Permission type |
Permissions (from least to most privileged) |
Delegated (work or school account) |
Policy.ReadWrite.ConsentRequest, Directory.ReadWrite.All |
Delegated (personal Microsoft account) |
Not supported. |
Application |
Policy.ReadWrite.ConsentRequest, Directory.ReadWrite.All |
When calling on behalf of a user, the user needs to belong to the Global Administrator directory role.
HTTP request
PUT /policies/adminConsentRequestPolicy
Name |
Description |
Authorization |
Bearer {token}. Required. |
Content-Type |
application/json. Required. |
Request body
In the request body, supply a JSON representation of the adminConsentRequestPolicy object.
The following table shows the properties that are required when you update the adminConsentRequestPolicy.
Property |
Type |
Description |
isEnabled |
Boolean |
Specifies whether the admin consent request feature is enabled or disabled. |
notifyReviewers |
Boolean |
Specifies whether reviewers will receive notifications. |
remindersEnabled |
Boolean |
Specifies whether reviewers will receive reminder emails. |
requestDurationInDays |
Int32 |
Specifies the duration the request is active before it automatically expires if no decision is applied. |
reviewers |
accessReviewReviewerScope collection |
The list of reviewers for the admin consent. |
Response
If successful, this method returns a 204 No content
response code and an updated adminConsentRequestPolicy object in the response body.
Examples
Request
PUT https://graph.microsoft.com/v1.0/policies/adminConsentRequestPolicy
Content-Type: application/json
{
"isEnabled": true,
"notifyReviewers": true,
"remindersEnabled": true,
"requestDurationInDays": 5,
"reviewers": [
{
"query": "/users/b6879be8-fb87-4482-a72e-18445d2b5c54",
"queryType": "MicrosoftGraph"
},
{
"query": "/users/b3427cc5-bf69-4dcd-95f7-ed1eb432f5e9",
"queryType": "MicrosoftGraph"
}
]
}
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
var requestBody = new Microsoft.Graph.Policies.AdminConsentRequestPolicy.AdminConsentRequestPolicyPutRequestBody
{
AdditionalData = new Dictionary<string, object>
{
{
"isEnabled" , true
},
{
"notifyReviewers" , true
},
{
"remindersEnabled" , true
},
{
"requestDurationInDays" , 5
},
{
"reviewers" , new List<>
{
new
{
Query = "/users/b6879be8-fb87-4482-a72e-18445d2b5c54",
QueryType = "MicrosoftGraph",
},
new
{
Query = "/users/b3427cc5-bf69-4dcd-95f7-ed1eb432f5e9",
QueryType = "MicrosoftGraph",
},
}
},
},
};
await graphClient.Policies.AdminConsentRequestPolicy.PutAsync(requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/Policies/AdminConsentRequestPolicy"
//other-imports
)
graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes)
requestBody := graphmodels.NewAdminConsentRequestPolicyPutRequestBody()
additionalData := map[string]interface{}{
isEnabled := true
requestBody.SetIsEnabled(&isEnabled)
notifyReviewers := true
requestBody.SetNotifyReviewers(¬ifyReviewers)
remindersEnabled := true
requestBody.SetRemindersEnabled(&remindersEnabled)
"requestDurationInDays" : int32(5) ,
:= graphmodels.New()
query := "/users/b6879be8-fb87-4482-a72e-18445d2b5c54"
.SetQuery(&query)
queryType := "MicrosoftGraph"
.SetQueryType(&queryType)
:= graphmodels.New()
query := "/users/b3427cc5-bf69-4dcd-95f7-ed1eb432f5e9"
.SetQuery(&query)
queryType := "MicrosoftGraph"
.SetQueryType(&queryType)
reviewers := []graphmodels.Objectable {
,
,
}
}
requestBody.SetAdditionalData(additionalData)
graphClient.Policies().AdminConsentRequestPolicy().Put(context.Background(), requestBody, nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
AdminConsentRequestPolicy adminConsentRequestPolicy = new AdminConsentRequestPolicy();
adminConsentRequestPolicy.isEnabled = true;
adminConsentRequestPolicy.notifyReviewers = true;
adminConsentRequestPolicy.remindersEnabled = true;
adminConsentRequestPolicy.requestDurationInDays = 5;
LinkedList<AccessReviewReviewerScope> reviewersList = new LinkedList<AccessReviewReviewerScope>();
AccessReviewReviewerScope reviewers = new AccessReviewReviewerScope();
reviewers.query = "/users/b6879be8-fb87-4482-a72e-18445d2b5c54";
reviewers.queryType = "MicrosoftGraph";
reviewersList.add(reviewers);
AccessReviewReviewerScope reviewers1 = new AccessReviewReviewerScope();
reviewers1.query = "/users/b3427cc5-bf69-4dcd-95f7-ed1eb432f5e9";
reviewers1.queryType = "MicrosoftGraph";
reviewersList.add(reviewers1);
adminConsentRequestPolicy.reviewers = reviewersList;
graphClient.policies().adminConsentRequestPolicy()
.buildRequest()
.put(adminConsentRequestPolicy);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
const options = {
authProvider,
};
const client = Client.init(options);
const adminConsentRequestPolicy = {
isEnabled: true,
notifyReviewers: true,
remindersEnabled: true,
requestDurationInDays: 5,
reviewers: [
{
query: '/users/b6879be8-fb87-4482-a72e-18445d2b5c54',
queryType: 'MicrosoftGraph'
},
{
query: '/users/b3427cc5-bf69-4dcd-95f7-ed1eb432f5e9',
queryType: 'MicrosoftGraph'
}
]
};
await client.api('/policies/adminConsentRequestPolicy')
.put(adminConsentRequestPolicy);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
<?php
// THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($requestAdapter);
$requestBody = new AdminConsentRequestPolicyPutRequestBody();
$additionalData = [
'isEnabled' => true,
'notifyReviewers' => true,
'remindersEnabled' => true,
'requestDurationInDays' => 5,
'reviewers' => $reviewers1 = new ();
$ reviewers1->setQuery('/users/b6879be8-fb87-4482-a72e-18445d2b5c54');
$ reviewers1->setQueryType('MicrosoftGraph');
$reviewersArray []= $reviewers1;
$reviewers2 = new ();
$ reviewers2->setQuery('/users/b3427cc5-bf69-4dcd-95f7-ed1eb432f5e9');
$ reviewers2->setQueryType('MicrosoftGraph');
$reviewersArray []= $reviewers2;
$requestBody->setReviewers($reviewersArray);
];
$requestBody->setAdditionalData($additionalData);
$graphServiceClient->policies()->adminConsentRequestPolicy()->put($requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Response
HTTP/1.1 204 No Content
Content-Type: text/plain