calendarPermission erstellen
Artikel
12/06/2021
2 Minuten Lesedauer
3 Mitwirkende
In diesem Artikel
Namespace: microsoft.graph
Erstellen Sie eine calendarPermission-Ressource, um die Identität und Rolle des Benutzers anzugeben, für den der angegebene Kalender freigegeben oder delegiert wird.
Berechtigungen
Je nach dem Typ des Kalenders, in dem sich das Ereignis befindet, und dem Typ der Berechtigung (delegierte Berechtigung oder Anwendungsberechtigung), ist eine der folgenden Berechtigungen erforderlich, um diese API aufzurufen. Weitere Informationen, unter anderem zur Auswahl von Berechtigungen, finden Sie unter Berechtigungen .
Kalender
Delegiert (Geschäfts-, Schul- oder Unikonto)
Delegiert (persönliches Microsoft-Konto)
Application
Benutzerkalender
Calendars.Read, Calendars.ReadWrite
Calendars.Read, Calendars.ReadWrite
Calendars.Read, Calendars.ReadWrite
Gruppenkalender
Group.Read.All, Group.ReadWrite.All
Nicht unterstützt
Nicht unterstützt
HTTP-Anforderung
Erstellen Sie die angegebenen Berechtigungen des primären Kalenders eines Benutzers:
POST /users/{id}/calendar/calendarPermissions
Erstellen Sie die angegebenen Berechtigungen eines Gruppenkalenders:
POST /groups/{id}/calendar/calendarPermissions
Erstellen Sie die angegebenen Berechtigungen des Benutzerkalenders, der das identifizierte Ereignis enthält:
POST /users/{id}/events/{id}/calendar/calendarPermissions
Name
Beschreibung
Authorization
Bearer {token}. Erforderlich.
Content-Type
application/json. Erforderlich.
Anforderungstext
Geben Sie im Anforderungstext eine JSON-Darstellung eines calendarPermission-Objekts an.
Antwort
Bei erfolgreicher Ausführung gibt die Methode den 200 OK Antwortcode und eine Auflistung von calendarPermission-Objekten im Antworttext zurück.
Beispiele
Anforderung
Nachfolgend sehen Sie ein Beispiel der Anforderung.
POST https://graph.microsoft.com/v1.0/me/calendar/calendarPermissions
{
"emailAddress": {
"name": "Samantha Booth",
"address": "samanthab@adatum.onmicrosoft.com"
},
"isInsideOrganization": true,
"isRemovable": true,
"role": "read"
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var calendarPermission = new CalendarPermission
{
EmailAddress = new EmailAddress
{
Name = "Samantha Booth",
Address = "samanthab@adatum.onmicrosoft.com"
},
IsInsideOrganization = true,
IsRemovable = true,
Role = CalendarRoleType.Read
};
await graphClient.Me.Calendar.CalendarPermissions
.Request()
.AddAsync(calendarPermission);
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
const options = {
authProvider,
};
const client = Client.init(options);
const calendarPermission = {
emailAddress: {
name: 'Samantha Booth',
address: 'samanthab@adatum.onmicrosoft.com'
},
isInsideOrganization: true,
isRemovable: true,
role: 'read'
};
await client.api('/me/calendar/calendarPermissions')
.post(calendarPermission);
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/me/calendar/calendarPermissions"]]];
[urlRequest setHTTPMethod:@"POST"];
MSGraphCalendarPermission *calendarPermission = [[MSGraphCalendarPermission alloc] init];
MSGraphEmailAddress *emailAddress = [[MSGraphEmailAddress alloc] init];
[emailAddress setName:@"Samantha Booth"];
[emailAddress setAddress:@"samanthab@adatum.onmicrosoft.com"];
[calendarPermission setEmailAddress:emailAddress];
[calendarPermission setIsInsideOrganization: true];
[calendarPermission setIsRemovable: true];
[calendarPermission setRole: [MSGraphCalendarRoleType read]];
NSError *error;
NSData *calendarPermissionData = [calendarPermission getSerializedDataWithError:&error];
[urlRequest setHTTPBody:calendarPermissionData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
CalendarPermission calendarPermission = new CalendarPermission();
EmailAddress emailAddress = new EmailAddress();
emailAddress.name = "Samantha Booth";
emailAddress.address = "samanthab@adatum.onmicrosoft.com";
calendarPermission.emailAddress = emailAddress;
calendarPermission.isInsideOrganization = true;
calendarPermission.isRemovable = true;
calendarPermission.role = CalendarRoleType.READ;
graphClient.me().calendar().calendarPermissions()
.buildRequest()
.post(calendarPermission);
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewCalendarPermission()
emailAddress := msgraphsdk.NewEmailAddress()
requestBody.SetEmailAddress(emailAddress)
name := "Samantha Booth"
emailAddress.SetName(&name)
address := "samanthab@adatum.onmicrosoft.com"
emailAddress.SetAddress(&address)
isInsideOrganization := true
requestBody.SetIsInsideOrganization(&isInsideOrganization)
isRemovable := true
requestBody.SetIsRemovable(&isRemovable)
role := "read"
requestBody.SetRole(&role)
result, err := graphClient.Me().Calendar().CalendarPermissions().Post(requestBody)
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
Antwort
Nachfolgend sehen Sie ein Beispiel der Antwort.
Hinweis: Das hier gezeigte Antwortobjekt kann zur besseren Lesbarkeit gekürzt werden.
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('458d4c95-124e-49da-ba9d-1dd0387e682e')/calendar/calendarPermissions/$entity",
"id": "RXhjaGFuZ2VQdWJsaXNoZWRVc2VyLnNhbWFudGhhYkBhZGF0dW0ub25taWNyb3NvZnQuY29t",
"isRemovable": true,
"isInsideOrganization": true,
"role": "read",
"allowedRoles": [
"freeBusyRead",
"limitedRead",
"read"
],
"emailAddress": {
"name": "Samantha Booth",
"address": "samanthab@adatum.onmicrosoft.com"
}
}