Namespace: microsoft.graph
Aktualisieren sie die Eigenschaften und Beziehungen eines shiftPreferences-Objekts .
Diese API ist in den folgenden nationalen Cloudbereitstellungen verfügbar.
| Weltweiter Service |
US Government L4 |
US Government L5 (DOD) |
China, betrieben von 21Vianet |
| ✅ |
❌ |
❌ |
❌ |
Berechtigungen
Wählen Sie die Berechtigungen aus, die für diese API als am wenigsten privilegiert markiert sind. Verwenden Sie eine höhere Berechtigung oder Berechtigungen nur, wenn Ihre App dies erfordert. Ausführliche Informationen zu delegierten Berechtigungen und Anwendungsberechtigungen finden Sie unter Berechtigungstypen. Weitere Informationen zu diesen Berechtigungen finden Sie in der Berechtigungsreferenz.
| Berechtigungstyp |
Berechtigungen mit den geringsten Berechtigungen |
Berechtigungen mit höheren Berechtigungen |
| Delegiert (Geschäfts-, Schul- oder Unikonto) |
User.ReadWrite.All |
AgentIdUser.ReadWrite.All, AgentIdUser.ReadWrite.IdentityParentedBy |
| Delegiert (persönliches Microsoft-Konto) |
Nicht unterstützt |
Nicht unterstützt |
| Application |
UserShiftPreferences.ReadWrite.All |
Nicht verfügbar. |
Hinweis: Diese API unterstützt Administratorberechtigungen. Benutzer mit Administratorrollen können auf Gruppen zugreifen, in denen sie kein Mitglied sind.
HTTP-Anforderung
PATCH /users/{userId}/settings/shiftPreferences
| Kopfzeile |
Wert |
| Authorization |
Bearer {token}. Erforderlich. Erfahren Sie mehr über Authentifizierung und Autorisierung. |
| Content-Type |
application/json. Erforderlich. |
| MS-APP-ACTS-AS (veraltet) |
Eine Benutzer-ID (GUID). Nur erforderlich, wenn das Autorisierungstoken ein Anwendungstoken ist. andernfalls optional. Der MS-APP-ACTS-AS Header ist veraltet und für Anwendungstoken nicht mehr erforderlich. |
Anforderungstext
Geben Sie im Anforderungstext eine JSON-Darstellung eines shiftPreferences-Objekts an.
Antwort
Wenn die Methode erfolgreich verläuft, wird der Antwortcode 204 NO CONTENT zurückgegeben.
Beispiel
Anforderung
Das folgende Beispiel zeigt eine Anfrage.
PATCH https://graph.microsoft.com/v1.0/users/871dbd5c-3a6a-4392-bfe1-042452793a50/settings/shiftPreferences
Content-type: application/json
{
"id": "SHPR_eeab4fb1-20e5-48ca-ad9b-98119d94bee7",
"@odata.etag": "1a371e53-f0a6-4327-a1ee-e3c56e4b38aa",
"availability": [
{
"recurrence": {
"pattern": {
"type": "Weekly",
"daysOfWeek": ["Monday", "Wednesday", "Friday"],
"interval": 1
},
"range": {
"type": "noEnd"
}
},
"timeZone": "Pacific Standard Time",
"timeSlots": null
}
]
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new ShiftPreferences
{
Id = "SHPR_eeab4fb1-20e5-48ca-ad9b-98119d94bee7",
Availability = new List<ShiftAvailability>
{
new ShiftAvailability
{
Recurrence = new PatternedRecurrence
{
Pattern = new RecurrencePattern
{
Type = RecurrencePatternType.Weekly,
DaysOfWeek = new List<DayOfWeekObject?>
{
DayOfWeekObject.Monday,
DayOfWeekObject.Wednesday,
DayOfWeekObject.Friday,
},
Interval = 1,
},
Range = new RecurrenceRange
{
Type = RecurrenceRangeType.NoEnd,
},
},
TimeZone = "Pacific Standard Time",
TimeSlots = null,
},
},
AdditionalData = new Dictionary<string, object>
{
{
"@odata.etag" , "1a371e53-f0a6-4327-a1ee-e3c56e4b38aa"
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Users["{user-id}"].Settings.ShiftPreferences.PatchAsync(requestBody);
Einzelheiten darüber, wie Sie das SDK zu Ihrem Projekt hinzufügen und eine authProvider-Instanz erstellen, finden Sie in der SDK-Dokumentation.
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewShiftPreferences()
id := "SHPR_eeab4fb1-20e5-48ca-ad9b-98119d94bee7"
requestBody.SetId(&id)
shiftAvailability := graphmodels.NewShiftAvailability()
recurrence := graphmodels.NewPatternedRecurrence()
pattern := graphmodels.NewRecurrencePattern()
type := graphmodels.WEEKLY_RECURRENCEPATTERNTYPE
pattern.SetType(&type)
daysOfWeek := []graphmodels.DayOfWeekable {
dayOfWeek := graphmodels.MONDAY_DAYOFWEEK
pattern.SetDayOfWeek(&dayOfWeek)
dayOfWeek := graphmodels.WEDNESDAY_DAYOFWEEK
pattern.SetDayOfWeek(&dayOfWeek)
dayOfWeek := graphmodels.FRIDAY_DAYOFWEEK
pattern.SetDayOfWeek(&dayOfWeek)
}
pattern.SetDaysOfWeek(daysOfWeek)
interval := int32(1)
pattern.SetInterval(&interval)
recurrence.SetPattern(pattern)
range := graphmodels.NewRecurrenceRange()
type := graphmodels.NOEND_RECURRENCERANGETYPE
range.SetType(&type)
recurrence.SetRange(range)
shiftAvailability.SetRecurrence(recurrence)
timeZone := "Pacific Standard Time"
shiftAvailability.SetTimeZone(&timeZone)
timeSlots := null
shiftAvailability.SetTimeSlots(&timeSlots)
availability := []graphmodels.ShiftAvailabilityable {
shiftAvailability,
}
requestBody.SetAvailability(availability)
additionalData := map[string]interface{}{
"@odata.etag" : "1a371e53-f0a6-4327-a1ee-e3c56e4b38aa",
}
requestBody.SetAdditionalData(additionalData)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
shiftPreferences, err := graphClient.Users().ByUserId("user-id").Settings().ShiftPreferences().Patch(context.Background(), requestBody, nil)
Einzelheiten darüber, wie Sie das SDK zu Ihrem Projekt hinzufügen und eine authProvider-Instanz erstellen, finden Sie in der SDK-Dokumentation.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
ShiftPreferences shiftPreferences = new ShiftPreferences();
shiftPreferences.setId("SHPR_eeab4fb1-20e5-48ca-ad9b-98119d94bee7");
LinkedList<ShiftAvailability> availability = new LinkedList<ShiftAvailability>();
ShiftAvailability shiftAvailability = new ShiftAvailability();
PatternedRecurrence recurrence = new PatternedRecurrence();
RecurrencePattern pattern = new RecurrencePattern();
pattern.setType(RecurrencePatternType.Weekly);
LinkedList<DayOfWeek> daysOfWeek = new LinkedList<DayOfWeek>();
daysOfWeek.add(DayOfWeek.Monday);
daysOfWeek.add(DayOfWeek.Wednesday);
daysOfWeek.add(DayOfWeek.Friday);
pattern.setDaysOfWeek(daysOfWeek);
pattern.setInterval(1);
recurrence.setPattern(pattern);
RecurrenceRange range = new RecurrenceRange();
range.setType(RecurrenceRangeType.NoEnd);
recurrence.setRange(range);
shiftAvailability.setRecurrence(recurrence);
shiftAvailability.setTimeZone("Pacific Standard Time");
shiftAvailability.setTimeSlots(null);
availability.add(shiftAvailability);
shiftPreferences.setAvailability(availability);
HashMap<String, Object> additionalData = new HashMap<String, Object>();
additionalData.put("@odata.etag", "1a371e53-f0a6-4327-a1ee-e3c56e4b38aa");
shiftPreferences.setAdditionalData(additionalData);
ShiftPreferences result = graphClient.users().byUserId("{user-id}").settings().shiftPreferences().patch(shiftPreferences);
Einzelheiten darüber, wie Sie das SDK zu Ihrem Projekt hinzufügen und eine authProvider-Instanz erstellen, finden Sie in der SDK-Dokumentation.
const options = {
authProvider,
};
const client = Client.init(options);
const shiftPreferences = {
id: 'SHPR_eeab4fb1-20e5-48ca-ad9b-98119d94bee7',
'@odata.etag': '1a371e53-f0a6-4327-a1ee-e3c56e4b38aa',
availability: [
{
recurrence: {
pattern: {
type: 'Weekly',
daysOfWeek: ['Monday', 'Wednesday', 'Friday'],
interval: 1
},
range: {
type: 'noEnd'
}
},
timeZone: 'Pacific Standard Time',
timeSlots: null
}
]
};
await client.api('/users/871dbd5c-3a6a-4392-bfe1-042452793a50/settings/shiftPreferences')
.update(shiftPreferences);
Einzelheiten darüber, wie Sie das SDK zu Ihrem Projekt hinzufügen und eine authProvider-Instanz erstellen, finden Sie in der SDK-Dokumentation.
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\ShiftPreferences;
use Microsoft\Graph\Generated\Models\ShiftAvailability;
use Microsoft\Graph\Generated\Models\PatternedRecurrence;
use Microsoft\Graph\Generated\Models\RecurrencePattern;
use Microsoft\Graph\Generated\Models\RecurrencePatternType;
use Microsoft\Graph\Generated\Models\DayOfWeek;
use Microsoft\Graph\Generated\Models\RecurrenceRange;
use Microsoft\Graph\Generated\Models\RecurrenceRangeType;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new ShiftPreferences();
$requestBody->setId('SHPR_eeab4fb1-20e5-48ca-ad9b-98119d94bee7');
$availabilityShiftAvailability1 = new ShiftAvailability();
$availabilityShiftAvailability1Recurrence = new PatternedRecurrence();
$availabilityShiftAvailability1RecurrencePattern = new RecurrencePattern();
$availabilityShiftAvailability1RecurrencePattern->setType(new RecurrencePatternType('weekly'));
$availabilityShiftAvailability1RecurrencePattern->setDaysOfWeek([new DayOfWeek('monday'),new DayOfWeek('wednesday'),new DayOfWeek('friday'), ]);
$availabilityShiftAvailability1RecurrencePattern->setInterval(1);
$availabilityShiftAvailability1Recurrence->setPattern($availabilityShiftAvailability1RecurrencePattern);
$availabilityShiftAvailability1RecurrenceRange = new RecurrenceRange();
$availabilityShiftAvailability1RecurrenceRange->setType(new RecurrenceRangeType('noEnd'));
$availabilityShiftAvailability1Recurrence->setRange($availabilityShiftAvailability1RecurrenceRange);
$availabilityShiftAvailability1->setRecurrence($availabilityShiftAvailability1Recurrence);
$availabilityShiftAvailability1->setTimeZone('Pacific Standard Time');
$availabilityShiftAvailability1->setTimeSlots(null);
$availabilityArray []= $availabilityShiftAvailability1;
$requestBody->setAvailability($availabilityArray);
$additionalData = [
'@odata.etag' => '1a371e53-f0a6-4327-a1ee-e3c56e4b38aa',
];
$requestBody->setAdditionalData($additionalData);
$result = $graphServiceClient->users()->byUserId('user-id')->settings()->shiftPreferences()->patch($requestBody)->wait();
Einzelheiten darüber, wie Sie das SDK zu Ihrem Projekt hinzufügen und eine authProvider-Instanz erstellen, finden Sie in der SDK-Dokumentation.
Import-Module Microsoft.Graph.Users
$params = @{
id = "SHPR_eeab4fb1-20e5-48ca-ad9b-98119d94bee7"
"@odata.etag" = "1a371e53-f0a6-4327-a1ee-e3c56e4b38aa"
availability = @(
@{
recurrence = @{
pattern = @{
type = "Weekly"
daysOfWeek = @(
"Monday"
"Wednesday"
"Friday"
)
interval = 1
}
range = @{
type = "noEnd"
}
}
timeZone = "Pacific Standard Time"
timeSlots = $null
}
)
}
Update-MgUserSettingShiftPreference -UserId $userId -BodyParameter $params
Einzelheiten darüber, wie Sie das SDK zu Ihrem Projekt hinzufügen und eine authProvider-Instanz erstellen, finden Sie in der SDK-Dokumentation.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.shift_preferences import ShiftPreferences
from msgraph.generated.models.shift_availability import ShiftAvailability
from msgraph.generated.models.patterned_recurrence import PatternedRecurrence
from msgraph.generated.models.recurrence_pattern import RecurrencePattern
from msgraph.generated.models.recurrence_pattern_type import RecurrencePatternType
from msgraph.generated.models.day_of_week import DayOfWeek
from msgraph.generated.models.recurrence_range import RecurrenceRange
from msgraph.generated.models.recurrence_range_type import RecurrenceRangeType
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = ShiftPreferences(
id = "SHPR_eeab4fb1-20e5-48ca-ad9b-98119d94bee7",
availability = [
ShiftAvailability(
recurrence = PatternedRecurrence(
pattern = RecurrencePattern(
type = RecurrencePatternType.Weekly,
days_of_week = [
DayOfWeek.Monday,
DayOfWeek.Wednesday,
DayOfWeek.Friday,
],
interval = 1,
),
range = RecurrenceRange(
type = RecurrenceRangeType.NoEnd,
),
),
time_zone = "Pacific Standard Time",
time_slots = None,
),
],
additional_data = {
"@odata_etag" : "1a371e53-f0a6-4327-a1ee-e3c56e4b38aa",
}
)
result = await graph_client.users.by_user_id('user-id').settings.shift_preferences.patch(request_body)
Einzelheiten darüber, wie Sie das SDK zu Ihrem Projekt hinzufügen und eine authProvider-Instanz erstellen, finden Sie in der SDK-Dokumentation.
Antwort
Das folgende Beispiel zeigt die Antwort.
HTTP/1.1 204 NO CONTENT