Namespace: microsoft.graph
Aktualisieren des Arbeitsorts eines Benutzers für den aktuellen Tag oder das aktuell aktive Segment. Durch diese Aktion wird der Arbeitsort des Benutzers schnell aktualisiert, ohne einzelne Vorkommen zu ändern.
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) |
Calendars.ReadWrite |
Nicht verfügbar. |
| Delegiert (persönliches Microsoft-Konto) |
Nicht unterstützt |
Nicht unterstützt |
| Application |
Calendars.ReadWrite.All |
Nicht verfügbar. |
Hinweis: Anwendungsberechtigungen werden nur bei Verwendung des Endpunkts /users/{id} unterstützt.
HTTP-Anforderung
POST /me/settings/workHoursAndLocations/occurrences/setCurrentLocation
Hinweis
Das Aufrufen des /me-Endpunkts erfordert einen angemeldeten Benutzer und daher eine delegierte Berechtigung. Anwendungsberechtigungen werden bei Verwendung des /me Endpunkts nicht unterstützt.
Wenn delegierte Berechtigungen mit dem /users/{id} Endpunkt verwendet werden, muss die ID die ID des angemeldeten Benutzers sein.
POST /users/{id | userPrincipalName}/settings/workHoursAndLocations/occurrences/setCurrentLocation
Anforderungstext
Geben Sie im Anforderungstext ein JSON-Objekt mit den folgenden Parametern an.
| Parameter |
Typ |
Beschreibung |
| placeId |
Zeichenfolge |
Bezeichner eines Ortes aus der Microsoft Graph Places Directory-API. Nur zutreffend, wenn workLocationType festgelegt ist auf office. |
| updateScope |
workLocationUpdateScope |
Der Umfang des Updates. Unterstützt eine Teilmenge der Werte von workLocationUpdateScope. Die möglichen Werte sind: currentSegment, currentDay. |
| workLocationType |
workLocationType |
Der neue festgelegte Arbeitsorttyp. Unterstützt eine Teilmenge der Werte von workLocationType. Die möglichen Werte sind: office, remote. |
workLocationUpdateScope-Werte
| Member |
Beschreibung |
| currentSegment |
Aktualisieren Sie nur das aktuelle Zeitsegment. |
| currentDay |
Aktualisieren des gesamten aktuellen Tages. |
| unknownFutureValue |
Evolvable Enumeration Sentinel-Wert. Nicht verwenden. |
Antwort
Wenn die Aktion erfolgreich verläuft, wird der Antwortcode 204 No Content zurückgegeben.
Beispiele
Beispiel 1: Festlegen des aktuellen Standorts auf "Büro"
Das folgende Beispiel zeigt, wie Sie den aktuellen Standort auf "Büro" festlegen.
Anforderung
Das folgende Beispiel zeigt eine Anfrage.
POST https://graph.microsoft.com/v1.0/me/settings/workHoursAndLocations/occurrences/setCurrentLocation
Content-type: application/json
{
"updateScope": "currentDay",
"workLocationType": "office",
"placeId": "12345678-1234-1234-1234-123456789012"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Me.Settings.WorkHoursAndLocations.Occurrences.SetCurrentLocation;
using Microsoft.Graph.Models;
var requestBody = new SetCurrentLocationPostRequestBody
{
UpdateScope = WorkLocationUpdateScope.CurrentDay,
WorkLocationType = WorkLocationType.Office,
PlaceId = "12345678-1234-1234-1234-123456789012",
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Me.Settings.WorkHoursAndLocations.Occurrences.SetCurrentLocation.PostAsync(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"
graphusers "github.com/microsoftgraph/msgraph-sdk-go/users"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphusers.NewItemSetCurrentLocationPostRequestBody()
updateScope := graphmodels.CURRENTDAY_WORKLOCATIONUPDATESCOPE
requestBody.SetUpdateScope(&updateScope)
workLocationType := graphmodels.OFFICE_WORKLOCATIONTYPE
requestBody.SetWorkLocationType(&workLocationType)
placeId := "12345678-1234-1234-1234-123456789012"
requestBody.SetPlaceId(&placeId)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.Me().Settings().WorkHoursAndLocations().Occurrences().SetCurrentLocation().Post(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);
com.microsoft.graph.users.item.settings.workhoursandlocations.occurrences.setcurrentlocation.SetCurrentLocationPostRequestBody setCurrentLocationPostRequestBody = new com.microsoft.graph.users.item.settings.workhoursandlocations.occurrences.setcurrentlocation.SetCurrentLocationPostRequestBody();
setCurrentLocationPostRequestBody.setUpdateScope(WorkLocationUpdateScope.CurrentDay);
setCurrentLocationPostRequestBody.setWorkLocationType(WorkLocationType.Office);
setCurrentLocationPostRequestBody.setPlaceId("12345678-1234-1234-1234-123456789012");
graphClient.me().settings().workHoursAndLocations().occurrences().setCurrentLocation().post(setCurrentLocationPostRequestBody);
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 setCurrentLocation = {
updateScope: 'currentDay',
workLocationType: 'office',
placeId: '12345678-1234-1234-1234-123456789012'
};
await client.api('/me/settings/workHoursAndLocations/occurrences/setCurrentLocation')
.post(setCurrentLocation);
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\Users\Item\Settings\WorkHoursAndLocations\Occurrences\SetCurrentLocation\SetCurrentLocationPostRequestBody;
use Microsoft\Graph\Generated\Models\WorkLocationUpdateScope;
use Microsoft\Graph\Generated\Models\WorkLocationType;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new SetCurrentLocationPostRequestBody();
$requestBody->setUpdateScope(new WorkLocationUpdateScope('currentDay'));
$requestBody->setWorkLocationType(new WorkLocationType('office'));
$requestBody->setPlaceId('12345678-1234-1234-1234-123456789012');
$graphServiceClient->me()->settings()->workHoursAndLocations()->occurrences()->setCurrentLocation()->post($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 = @{
updateScope = "currentDay"
workLocationType = "office"
placeId = "12345678-1234-1234-1234-123456789012"
}
# A UPN can also be used as -UserId.
Set-MgUserSettingWorkHourAndLocationOccurrenceCurrentLocation -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.users.item.settings.workhoursandlocations.occurrences.set_current_location.set_current_location_post_request_body import SetCurrentLocationPostRequestBody
from msgraph.generated.models.work_location_update_scope import WorkLocationUpdateScope
from msgraph.generated.models.work_location_type import WorkLocationType
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = SetCurrentLocationPostRequestBody(
update_scope = WorkLocationUpdateScope.CurrentDay,
work_location_type = WorkLocationType.Office,
place_id = "12345678-1234-1234-1234-123456789012",
)
await graph_client.me.settings.work_hours_and_locations.occurrences.set_current_location.post(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
Beispiel 2: Festlegen des aktuellen Standorts auf "Remote"
Das folgende Beispiel zeigt, wie Sie den aktuellen Standort auf "Remote" festlegen.
Anforderung
Das folgende Beispiel zeigt eine Anfrage.
POST https://graph.microsoft.com/v1.0/me/settings/workHoursAndLocations/occurrences/setCurrentLocation
Content-type: application/json
{
"updateScope": "currentSegment",
"workLocationType": "remote"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Me.Settings.WorkHoursAndLocations.Occurrences.SetCurrentLocation;
using Microsoft.Graph.Models;
var requestBody = new SetCurrentLocationPostRequestBody
{
UpdateScope = WorkLocationUpdateScope.CurrentSegment,
WorkLocationType = WorkLocationType.Remote,
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Me.Settings.WorkHoursAndLocations.Occurrences.SetCurrentLocation.PostAsync(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"
graphusers "github.com/microsoftgraph/msgraph-sdk-go/users"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphusers.NewItemSetCurrentLocationPostRequestBody()
updateScope := graphmodels.CURRENTSEGMENT_WORKLOCATIONUPDATESCOPE
requestBody.SetUpdateScope(&updateScope)
workLocationType := graphmodels.REMOTE_WORKLOCATIONTYPE
requestBody.SetWorkLocationType(&workLocationType)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.Me().Settings().WorkHoursAndLocations().Occurrences().SetCurrentLocation().Post(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);
com.microsoft.graph.users.item.settings.workhoursandlocations.occurrences.setcurrentlocation.SetCurrentLocationPostRequestBody setCurrentLocationPostRequestBody = new com.microsoft.graph.users.item.settings.workhoursandlocations.occurrences.setcurrentlocation.SetCurrentLocationPostRequestBody();
setCurrentLocationPostRequestBody.setUpdateScope(WorkLocationUpdateScope.CurrentSegment);
setCurrentLocationPostRequestBody.setWorkLocationType(WorkLocationType.Remote);
graphClient.me().settings().workHoursAndLocations().occurrences().setCurrentLocation().post(setCurrentLocationPostRequestBody);
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\Users\Item\Settings\WorkHoursAndLocations\Occurrences\SetCurrentLocation\SetCurrentLocationPostRequestBody;
use Microsoft\Graph\Generated\Models\WorkLocationUpdateScope;
use Microsoft\Graph\Generated\Models\WorkLocationType;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new SetCurrentLocationPostRequestBody();
$requestBody->setUpdateScope(new WorkLocationUpdateScope('currentSegment'));
$requestBody->setWorkLocationType(new WorkLocationType('remote'));
$graphServiceClient->me()->settings()->workHoursAndLocations()->occurrences()->setCurrentLocation()->post($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.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.users.item.settings.workhoursandlocations.occurrences.set_current_location.set_current_location_post_request_body import SetCurrentLocationPostRequestBody
from msgraph.generated.models.work_location_update_scope import WorkLocationUpdateScope
from msgraph.generated.models.work_location_type import WorkLocationType
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = SetCurrentLocationPostRequestBody(
update_scope = WorkLocationUpdateScope.CurrentSegment,
work_location_type = WorkLocationType.Remote,
)
await graph_client.me.settings.work_hours_and_locations.occurrences.set_current_location.post(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