Namespace: microsoft.graph
Wichtig
Die APIs unter der /beta Version in Microsoft Graph können sich ändern. Die Verwendung dieser APIs in Produktionsanwendungen wird nicht unterstützt. Um festzustellen, ob eine API in v1.0 verfügbar ist, verwenden Sie die Version Selektor.
Aktualisieren Sie den automatischen Arbeitsort für einen Benutzer. Die automatische Ebene ist teil des Standardrangfolgenmodells:
- Rangfolge: manuell > automatisch > geplant
- Genauigkeit (innerhalb derselben Ebene): Präzisere Gewinne (z. B. Büro + Gebäude > )
- Wenn ein manueller Speicherort festgelegt ist, werden sowohl die automatischen als auch die geplanten Einstellungen überschrieben.
Verwenden Sie diesen Vorgang von Clients oder Diensten, die den Standort automatisch erkennen (z. B. Teams, Netzwerk- und Standort-Agents oder OEM-Docking-Apps). Manuelle oder geplante Signale werden nicht gelöscht.
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 |
Berechtigung mit den geringsten Rechten |
Berechtigungen mit höheren Berechtigungen |
| Delegiert (Geschäfts-, Schul- oder Unikonto) |
Presence.ReadWrite |
Nicht verfügbar. |
| Delegiert (persönliches Microsoft-Konto) |
Nicht unterstützt |
Nicht unterstützt |
| Application |
Nicht unterstützt |
Nicht unterstützt |
HTTP-Anforderung
POST /me/presence/setAutomaticLocation
Anforderungstext
Geben Sie im Anforderungstext eine JSON-Darstellung der Parameter an.
In der folgenden Tabelle sind die Parameter aufgeführt, die beim Aufrufen dieser Aktion erforderlich sind.
| Parameter |
Typ |
Beschreibung |
| placeId |
Zeichenfolge |
Bezeichner des Ortes, falls zutreffend. |
| workLocationType |
workLocationType |
Semantischer Typ des Speicherorts. Unterstützt eine Teilmenge der Werte für workLocationType. Die möglichen Werte sind: office, remote, timeOff. |
Antwort
Wenn die Aktion erfolgreich verläuft, wird der Antwortcode 200 OK zurückgegeben. Es gibt nichts im Antworttext zurück.
Beispiele
Anforderung
Das folgende Beispiel zeigt eine Anfrage.
POST https://graph.microsoft.com/beta/me/presence/setAutomaticLocation
Content-Type: application/json
{
"workLocationType": "office",
"placeId": "eb706f15-137e-4722-b4d1-b601481d9251"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Me.Presence.SetAutomaticLocation;
using Microsoft.Graph.Beta.Models;
var requestBody = new SetAutomaticLocationPostRequestBody
{
WorkLocationType = WorkLocationType.Office,
PlaceId = "eb706f15-137e-4722-b4d1-b601481d9251",
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Me.Presence.SetAutomaticLocation.PostAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphusers "github.com/microsoftgraph/msgraph-beta-sdk-go/users"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphusers.NewItemSetAutomaticLocationPostRequestBody()
workLocationType := graphmodels.OFFICE_WORKLOCATIONTYPE
requestBody.SetWorkLocationType(&workLocationType)
placeId := "eb706f15-137e-4722-b4d1-b601481d9251"
requestBody.SetPlaceId(&placeId)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.Me().Presence().SetAutomaticLocation().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.beta.users.item.presence.setautomaticlocation.SetAutomaticLocationPostRequestBody setAutomaticLocationPostRequestBody = new com.microsoft.graph.beta.users.item.presence.setautomaticlocation.SetAutomaticLocationPostRequestBody();
setAutomaticLocationPostRequestBody.setWorkLocationType(WorkLocationType.Office);
setAutomaticLocationPostRequestBody.setPlaceId("eb706f15-137e-4722-b4d1-b601481d9251");
graphClient.me().presence().setAutomaticLocation().post(setAutomaticLocationPostRequestBody);
const options = {
authProvider,
};
const client = Client.init(options);
const setAutomaticLocation = {
workLocationType: 'office',
placeId: 'eb706f15-137e-4722-b4d1-b601481d9251'
};
await client.api('/me/presence/setAutomaticLocation')
.version('beta')
.post(setAutomaticLocation);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Users\Item\Presence\SetAutomaticLocation\SetAutomaticLocationPostRequestBody;
use Microsoft\Graph\Beta\Generated\Models\WorkLocationType;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new SetAutomaticLocationPostRequestBody();
$requestBody->setWorkLocationType(new WorkLocationType('office'));
$requestBody->setPlaceId('eb706f15-137e-4722-b4d1-b601481d9251');
$graphServiceClient->me()->presence()->setAutomaticLocation()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.CloudCommunications
$params = @{
workLocationType = "office"
placeId = "eb706f15-137e-4722-b4d1-b601481d9251"
}
# A UPN can also be used as -UserId.
Set-MgBetaUserPresenceAutomaticLocation -UserId $userId -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.users.item.presence.set_automatic_location.set_automatic_location_post_request_body import SetAutomaticLocationPostRequestBody
from msgraph_beta.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 = SetAutomaticLocationPostRequestBody(
work_location_type = WorkLocationType.Office,
place_id = "eb706f15-137e-4722-b4d1-b601481d9251",
)
await graph_client.me.presence.set_automatic_location.post(request_body)
Antwort
Das folgende Beispiel zeigt die Antwort.
HTTP/1.1 200 OK