Espacio de nombres: microsoft.graph
Importante
Las API de la versión /beta de Microsoft Graph están sujetas a cambios. No se admite el uso de estas API en aplicaciones de producción. Para determinar si una API está disponible en la versión 1.0, use el selector de Versión.
Actualice la ubicación del trabajo para el día actual o el segmento activo actual. Esta acción le permite actualizar rápidamente la ubicación del trabajo sin modificar las repeticiones individuales.
Esta API está disponible en las siguientes implementaciones nacionales de nube.
| Servicio global |
Gobierno de EE. UU. L4 |
Us Government L5 (DOD) |
China operada por 21Vianet |
| ✅ |
❌ |
❌ |
❌ |
Permissions
Elija el permiso o los permisos marcados como con privilegios mínimos para esta API. Use un permiso o permisos con privilegios superiores solo si la aplicación lo requiere. Para obtener más información sobre los permisos delegados y de aplicación, consulte Tipos de permisos. Para obtener más información sobre estos permisos, consulte la referencia de permisos.
| Tipo de permiso |
Permisos con privilegios mínimos |
Permisos con privilegios más altos |
| Delegado (cuenta profesional o educativa) |
Calendars.ReadWrite |
No disponible. |
| Delegado (cuenta personal de Microsoft) |
No admitida. |
No admitida. |
| Aplicación |
No admitida. |
No admitida. |
Solicitud HTTP
POST /me/settings/workHoursAndLocations/occurrences/setCurrentLocation
Nota:
Para llamar al punto de conexión /me, se requiere un usuario con la sesión iniciada y, por lo tanto, un permiso delegado. Los permisos de aplicación no se admiten cuando se usa el punto de /me conexión.
Cuando se usa el punto de /users/{id} conexión, el identificador debe ser su propio identificador de usuario.
POST /users/{id | userPrincipalName}/settings/workHoursAndLocations/occurrences/setCurrentLocation
| Nombre |
Descripción |
| Authorization |
{token} de portador. Obligatorio. Obtenga más información sobre la autenticación y la autorización. |
| Content-Type |
application/json. Obligatorio. |
Cuerpo de la solicitud
En el cuerpo de la solicitud, proporcione un objeto JSON con los siguientes parámetros.
| Parámetro |
Tipo |
Description |
| placeId |
Cadena |
Identificador de un lugar de la API de Directorio de Microsoft Graph Places. Solo se aplica cuando workLocationType está establecido en office. |
| updateScope |
workLocationUpdateScope |
Ámbito de la actualización. Admite un subconjunto de los valores de workLocationUpdateScope. Los valores posibles son: currentSegment, currentDay. |
| workLocationType |
workLocationType |
Nuevo tipo de ubicación de trabajo que se va a establecer. Admite un subconjunto de los valores de workLocationType. Los valores posibles son: office, remote. |
workLocationUpdateScope valores
| Member |
Descripción |
| currentSegment |
Actualice solo el segmento de hora actual. |
| currentDay |
Actualice todo el día actual. |
| unknownFutureValue |
Valor de sentinel de enumeración evolvable. No usar. |
Respuesta
Si se ejecuta correctamente, esta acción devuelve un código de respuesta 204 No Content.
Ejemplos
Ejemplo 1: Establecer la ubicación actual en office
En el ejemplo siguiente se muestra cómo establecer la ubicación actual en office.
Solicitud
En el ejemplo siguiente se muestra la solicitud.
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)
Respuesta
En el ejemplo siguiente se muestra la respuesta.
HTTP/1.1 204 No Content
Ejemplo 2: Establecer la ubicación actual en remota
En el ejemplo siguiente se muestra cómo establecer la ubicación actual en remota.
Solicitud
En el ejemplo siguiente se muestra la solicitud.
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)
Respuesta
En el ejemplo siguiente se muestra la respuesta.
HTTP/1.1 204 No Content