Namespace: microsoft.graph
Importante
As APIs na versão /beta no Microsoft Graph estão sujeitas a alterações. Não há suporte para o uso dessas APIs em aplicativos de produção. Para determinar se uma API está disponível na v1.0, use o seletor Versão.
Atualize a sua localização de trabalho para o dia atual ou segmento ativo atual. Esta ação permite-lhe atualizar rapidamente a sua localização de trabalho sem modificar ocorrências individuais.
Esta API está disponível nas seguintes implementações de cloud nacionais.
| Serviço global |
US Government L4 |
US Government L5 (DOD) |
China operada pela 21Vianet |
| ✅ |
❌ |
❌ |
❌ |
Permissões
Escolha a permissão ou permissões marcadas como menos privilegiadas para esta API. Utilize uma permissão ou permissões com privilégios mais elevados apenas se a sua aplicação o exigir. Para obter detalhes sobre as permissões delegadas e de aplicação, veja Tipos de permissão. Para saber mais sobre estas permissões, veja a referência de permissões.
| Tipo de permissão |
Permissões com menos privilégios |
Permissões com privilégios superiores |
| Delegado (conta corporativa ou de estudante) |
Calendars.ReadWrite |
Indisponível. |
| Delegado (conta pessoal da Microsoft) |
Sem suporte. |
Sem suporte. |
| Aplicativo |
Sem suporte. |
Sem suporte. |
Solicitação HTTP
POST /me/settings/workHoursAndLocations/occurrences/setCurrentLocation
Observação
Chamar o ponto de extremidade /me exige um usuário conectado e, portanto, uma permissão delegada. As permissões de aplicação não são suportadas ao utilizar o /me ponto final.
Ao utilizar o /users/{id} ponto final, o ID tem de ser o seu próprio ID de utilizador.
POST /users/{id | userPrincipalName}/settings/workHoursAndLocations/occurrences/setCurrentLocation
| Nome |
Descrição |
| Autorização |
{token} de portador. Obrigatório. Saiba mais sobre autenticação e autorização. |
| Content-Type |
application/json. Obrigatório. |
Corpo da solicitação
Forneça um objeto JSON com os seguintes parâmetros no corpo da solicitação.
| Parâmetro |
Tipo |
Descrição |
| placeId |
Cadeia de caracteres |
Identificador de um local da API de Diretório de Places do Microsoft Graph. Aplicável apenas quando workLocationType está definido como office. |
| updateScope |
workLocationUpdateScope |
O âmbito da atualização. Suporta um subconjunto dos valores de workLocationUpdateScope. Os valores possíveis são: currentSegment, currentDay. |
| workLocationType |
workLocationType |
O novo tipo de localização de trabalho a definir. Suporta um subconjunto dos valores de workLocationType. Os valores possíveis são: office, remote. |
valores workLocationUpdateScope
| Member |
Descrição |
| currentSegment |
Atualize apenas o segmento de hora atual. |
| currentDay |
Atualize todo o dia atual. |
| unknownFutureValue |
Valor da sentinela de enumeração evoluível. Não usar. |
Resposta
Se tiver êxito, esta ação retornará um código de resposta 204 No Content.
Exemplos
Exemplo 1: Definir a localização atual para o office
O exemplo seguinte mostra como definir a localização atual para o office.
Solicitação
O exemplo a seguir mostra uma solicitação.
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)
Resposta
O exemplo a seguir mostra a resposta.
HTTP/1.1 204 No Content
Exemplo 2: Definir a localização atual como remota
O exemplo seguinte mostra como definir a localização atual como remota.
Solicitação
O exemplo a seguir mostra uma solicitação.
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)
Resposta
O exemplo a seguir mostra a resposta.
HTTP/1.1 204 No Content