Espace de noms: microsoft.graph
Importante
Les API sous la version /beta dans Microsoft Graph sont susceptibles d’être modifiées. L’utilisation de ces API dans des applications de production n’est pas prise en charge. Pour déterminer si une API est disponible dans v1.0, utilisez le sélecteur Version .
Mettez à jour le lieu de travail d’un utilisateur pour le jour en cours ou le segment actif actuel. Cette action met rapidement à jour le lieu de travail de l’utilisateur sans modifier les occurrences individuelles.
Cette API est disponible dans les déploiements cloud nationaux suivants.
| Service global |
Gouvernement américain L4 |
Gouvernement américain L5 (DOD) |
Chine exploitée par 21Vianet |
| ✅ |
✅ |
✅ |
❌ |
Autorisations
Choisissez l’autorisation ou les autorisations marquées comme étant les moins privilégiées pour cette API. Utilisez une ou plusieurs autorisations privilégiées uniquement si votre application en a besoin. Pour plus d’informations sur les autorisations déléguées et d’application, voir Types d’autorisations. Pour en savoir plus sur ces autorisations, consultez la référence des autorisations.
| Type d’autorisation |
Autorisations les moins privilégiées |
Autorisations à privilèges plus élevés |
| Déléguée (compte professionnel ou scolaire) |
Calendars.ReadWrite |
Non disponible. |
| Déléguée (compte Microsoft personnel) |
Non prise en charge. |
Non prise en charge. |
| Application |
Non prise en charge. |
Non prise en charge. |
Remarque : Les autorisations d’application ne sont prises en charge que si vous utilisez le point de /users/{id} terminaison.
Requête HTTP
POST /me/settings/workHoursAndLocations/occurrences/setCurrentLocation
Remarque
L’appel du point de terminaison /me nécessite un utilisateur connecté et par conséquent une autorisation déléguée. Les autorisations d’application ne sont pas prises en charge lors de l’utilisation du point de /me terminaison.
Lorsque vous utilisez des autorisations déléguées avec le point de /users/{id} terminaison, l’ID doit être l’ID de l’utilisateur connecté.
POST /users/{id | userPrincipalName}/settings/workHoursAndLocations/occurrences/setCurrentLocation
Corps de la demande
Dans le corps de la demande, indiquez un objet JSON avec les paramètres suivants.
| Paramètre |
Type |
Description |
| id de lieu |
String |
Identificateur d’un lieu de l’API Microsoft Graph Places Directory. S’applique uniquement lorsque workLocationType est défini sur office. |
| updateScope |
workLocationUpdateScope |
Portée de la mise à jour. Prend en charge un sous-ensemble des valeurs de workLocationUpdateScope. Les valeurs possibles sont : currentSegment, currentDay. |
| workLocationType |
workLocationType |
Nouveau type de lieu de travail à définir. Prend en charge un sous-ensemble des valeurs de workLocationType. Les valeurs possibles sont : office, remote. |
valeurs workLocationUpdateScope
| Member |
Description |
| currentSegment |
Mettez à jour uniquement le segment temporel actuel. |
| currentDay |
Mettez à jour la journée en cours. |
| unknownFutureValue |
Valeur sentinelle d’énumération évolutive. Ne pas utiliser. |
Réponse
Si elle réussit, cette action renvoie un code de réponse 204 No Content.
Exemples
Exemple 1 : définir l’emplacement actuel sur office
L’exemple suivant montre comment définir l’emplacement actuel sur office.
Demande
L’exemple suivant illustre une demande.
POST https://graph.microsoft.com/beta/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.Beta.Me.Settings.WorkHoursAndLocations.Occurrences.SetCurrentLocation;
using Microsoft.Graph.Beta.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);
// 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.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)
// 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.settings.workhoursandlocations.occurrences.setcurrentlocation.SetCurrentLocationPostRequestBody setCurrentLocationPostRequestBody = new com.microsoft.graph.beta.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);
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')
.version('beta')
.post(setCurrentLocation);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Users\Item\Settings\WorkHoursAndLocations\Occurrences\SetCurrentLocation\SetCurrentLocationPostRequestBody;
use Microsoft\Graph\Beta\Generated\Models\WorkLocationUpdateScope;
use Microsoft\Graph\Beta\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();
Import-Module Microsoft.Graph.Beta.Users
$params = @{
updateScope = "currentDay"
workLocationType = "office"
placeId = "12345678-1234-1234-1234-123456789012"
}
# A UPN can also be used as -UserId.
Set-MgBetaUserSettingWorkHourAndLocationOccurrenceCurrentLocation -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.settings.workhoursandlocations.occurrences.set_current_location.set_current_location_post_request_body import SetCurrentLocationPostRequestBody
from msgraph_beta.generated.models.work_location_update_scope import WorkLocationUpdateScope
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 = 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)
Réponse
L’exemple suivant illustre la réponse.
HTTP/1.1 204 No Content
Exemple 2 : définir l’emplacement actuel sur distant
L’exemple suivant montre comment définir l’emplacement actuel sur distant.
Demande
L’exemple suivant illustre une demande.
POST https://graph.microsoft.com/beta/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.Beta.Me.Settings.WorkHoursAndLocations.Occurrences.SetCurrentLocation;
using Microsoft.Graph.Beta.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);
// 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.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)
// 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.settings.workhoursandlocations.occurrences.setcurrentlocation.SetCurrentLocationPostRequestBody setCurrentLocationPostRequestBody = new com.microsoft.graph.beta.users.item.settings.workhoursandlocations.occurrences.setcurrentlocation.SetCurrentLocationPostRequestBody();
setCurrentLocationPostRequestBody.setUpdateScope(WorkLocationUpdateScope.CurrentSegment);
setCurrentLocationPostRequestBody.setWorkLocationType(WorkLocationType.Remote);
graphClient.me().settings().workHoursAndLocations().occurrences().setCurrentLocation().post(setCurrentLocationPostRequestBody);
const options = {
authProvider,
};
const client = Client.init(options);
const setCurrentLocation = {
updateScope: 'currentSegment',
workLocationType: 'remote'
};
await client.api('/me/settings/workHoursAndLocations/occurrences/setCurrentLocation')
.version('beta')
.post(setCurrentLocation);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Users\Item\Settings\WorkHoursAndLocations\Occurrences\SetCurrentLocation\SetCurrentLocationPostRequestBody;
use Microsoft\Graph\Beta\Generated\Models\WorkLocationUpdateScope;
use Microsoft\Graph\Beta\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();
Import-Module Microsoft.Graph.Beta.Users
$params = @{
updateScope = "currentSegment"
workLocationType = "remote"
}
# A UPN can also be used as -UserId.
Set-MgBetaUserSettingWorkHourAndLocationOccurrenceCurrentLocation -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.settings.workhoursandlocations.occurrences.set_current_location.set_current_location_post_request_body import SetCurrentLocationPostRequestBody
from msgraph_beta.generated.models.work_location_update_scope import WorkLocationUpdateScope
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 = 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)
Réponse
L’exemple suivant illustre la réponse.
HTTP/1.1 204 No Content