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.
Crear una nueva instancia de turno en una programación.
La duración de un turno no puede ser inferior a 1 minuto ni superior a 24 horas.
Esta API está disponible en las siguientes implementaciones en la nube nacional.
| Servicio global |
Administración pública de EE. UU. |
Gobierno de EE. UU. L5 (DOD) |
China operado por 21Vianet |
| ✅ |
❌ |
❌ |
❌ |
Permisos
Se requiere uno de los siguientes permisos para llamar a esta API. Para obtener más información, incluido cómo elegir permisos, vea Permisos.
| Tipo de permiso |
Permisos (de menos a más privilegiados) |
| Delegado (cuenta profesional o educativa) |
Group.ReadWrite.All |
| Delegado (cuenta personal de Microsoft) |
No admitida. |
| Aplicación |
Schedule.ReadWrite.All* |
Solicitud HTTP
POST /teams/{teamId}/schedule/shifts
| Encabezado |
Valor |
| Authorization |
{token} de portador. Obligatorio. Obtenga más información sobre autenticación y autorización. |
| Content-Type |
application/json. Obligatorio. |
| MS-APP-ACTS-AS (en desuso) |
Un identificador de usuario (GUID). Solo es necesario si el token de autorización es un token de aplicación; De lo contrario, es opcional. El MS-APP-ACTS-AS encabezado está en desuso y ya no es necesario con los tokens de aplicación. |
Respuesta
Si tiene éxito, este método devuelve un 201 Created código de respuesta y un objeto shift en el cuerpo de la respuesta.
Ejemplo
Solicitud
En el ejemplo siguiente se muestra la solicitud.
POST https://graph.microsoft.com/beta/teams/{teamId}/schedule/shifts
Content-type: application/json
{
"id": "SHFT_577b75d2-a927-48c0-a5d1-dc984894e7b8",
"userId": "c5d0c76b-80c4-481c-be50-923cd8d680a1",
"schedulingGroupId": "TAG_228940ed-ff84-4e25-b129-1b395cf78be0",
"sharedShift": {
"displayName": "Day shift",
"notes": "Please do inventory as part of your shift.",
"startDateTime": "2019-03-11T15:00:00Z",
"endDateTime": "2019-03-12T00:00:00Z",
"theme": "blue",
"activities": [
{
"isPaid": true,
"startDateTime": "2019-03-11T15:00:00Z",
"endDateTime": "2019-03-11T15:15:00Z",
"code": "",
"displayName": "Lunch"
}
]
},
"draftShift": {
"displayName": "Day shift",
"notes": "Please do inventory as part of your shift.",
"startDateTime": "2019-03-11T15:00:00Z",
"endDateTime": "2019-03-12T00:00:00Z",
"theme": "blue",
"activities": [
{
"isPaid": true,
"startDateTime": "2019-03-11T15:00:00Z",
"endDateTime": "2019-03-11T15:30:00Z",
"code": "",
"displayName": "Lunch"
}
]
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new Shift
{
Id = "SHFT_577b75d2-a927-48c0-a5d1-dc984894e7b8",
UserId = "c5d0c76b-80c4-481c-be50-923cd8d680a1",
SchedulingGroupId = "TAG_228940ed-ff84-4e25-b129-1b395cf78be0",
SharedShift = new ShiftItem
{
DisplayName = "Day shift",
Notes = "Please do inventory as part of your shift.",
StartDateTime = DateTimeOffset.Parse("2019-03-11T15:00:00Z"),
EndDateTime = DateTimeOffset.Parse("2019-03-12T00:00:00Z"),
Theme = ScheduleEntityTheme.Blue,
Activities = new List<ShiftActivity>
{
new ShiftActivity
{
IsPaid = true,
StartDateTime = DateTimeOffset.Parse("2019-03-11T15:00:00Z"),
EndDateTime = DateTimeOffset.Parse("2019-03-11T15:15:00Z"),
Code = "",
DisplayName = "Lunch",
},
},
},
DraftShift = new ShiftItem
{
DisplayName = "Day shift",
Notes = "Please do inventory as part of your shift.",
StartDateTime = DateTimeOffset.Parse("2019-03-11T15:00:00Z"),
EndDateTime = DateTimeOffset.Parse("2019-03-12T00:00:00Z"),
Theme = ScheduleEntityTheme.Blue,
Activities = new List<ShiftActivity>
{
new ShiftActivity
{
IsPaid = true,
StartDateTime = DateTimeOffset.Parse("2019-03-11T15:00:00Z"),
EndDateTime = DateTimeOffset.Parse("2019-03-11T15:30:00Z"),
Code = "",
DisplayName = "Lunch",
},
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Teams["{team-id}"].Schedule.Shifts.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"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewShift()
id := "SHFT_577b75d2-a927-48c0-a5d1-dc984894e7b8"
requestBody.SetId(&id)
userId := "c5d0c76b-80c4-481c-be50-923cd8d680a1"
requestBody.SetUserId(&userId)
schedulingGroupId := "TAG_228940ed-ff84-4e25-b129-1b395cf78be0"
requestBody.SetSchedulingGroupId(&schedulingGroupId)
sharedShift := graphmodels.NewShiftItem()
displayName := "Day shift"
sharedShift.SetDisplayName(&displayName)
notes := "Please do inventory as part of your shift."
sharedShift.SetNotes(¬es)
startDateTime , err := time.Parse(time.RFC3339, "2019-03-11T15:00:00Z")
sharedShift.SetStartDateTime(&startDateTime)
endDateTime , err := time.Parse(time.RFC3339, "2019-03-12T00:00:00Z")
sharedShift.SetEndDateTime(&endDateTime)
theme := graphmodels.BLUE_SCHEDULEENTITYTHEME
sharedShift.SetTheme(&theme)
shiftActivity := graphmodels.NewShiftActivity()
isPaid := true
shiftActivity.SetIsPaid(&isPaid)
startDateTime , err := time.Parse(time.RFC3339, "2019-03-11T15:00:00Z")
shiftActivity.SetStartDateTime(&startDateTime)
endDateTime , err := time.Parse(time.RFC3339, "2019-03-11T15:15:00Z")
shiftActivity.SetEndDateTime(&endDateTime)
code := ""
shiftActivity.SetCode(&code)
displayName := "Lunch"
shiftActivity.SetDisplayName(&displayName)
activities := []graphmodels.ShiftActivityable {
shiftActivity,
}
sharedShift.SetActivities(activities)
requestBody.SetSharedShift(sharedShift)
draftShift := graphmodels.NewShiftItem()
displayName := "Day shift"
draftShift.SetDisplayName(&displayName)
notes := "Please do inventory as part of your shift."
draftShift.SetNotes(¬es)
startDateTime , err := time.Parse(time.RFC3339, "2019-03-11T15:00:00Z")
draftShift.SetStartDateTime(&startDateTime)
endDateTime , err := time.Parse(time.RFC3339, "2019-03-12T00:00:00Z")
draftShift.SetEndDateTime(&endDateTime)
theme := graphmodels.BLUE_SCHEDULEENTITYTHEME
draftShift.SetTheme(&theme)
shiftActivity := graphmodels.NewShiftActivity()
isPaid := true
shiftActivity.SetIsPaid(&isPaid)
startDateTime , err := time.Parse(time.RFC3339, "2019-03-11T15:00:00Z")
shiftActivity.SetStartDateTime(&startDateTime)
endDateTime , err := time.Parse(time.RFC3339, "2019-03-11T15:30:00Z")
shiftActivity.SetEndDateTime(&endDateTime)
code := ""
shiftActivity.SetCode(&code)
displayName := "Lunch"
shiftActivity.SetDisplayName(&displayName)
activities := []graphmodels.ShiftActivityable {
shiftActivity,
}
draftShift.SetActivities(activities)
requestBody.SetDraftShift(draftShift)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
shifts, err := graphClient.Teams().ByTeamId("team-id").Schedule().Shifts().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Shift shift = new Shift();
shift.setId("SHFT_577b75d2-a927-48c0-a5d1-dc984894e7b8");
shift.setUserId("c5d0c76b-80c4-481c-be50-923cd8d680a1");
shift.setSchedulingGroupId("TAG_228940ed-ff84-4e25-b129-1b395cf78be0");
ShiftItem sharedShift = new ShiftItem();
sharedShift.setDisplayName("Day shift");
sharedShift.setNotes("Please do inventory as part of your shift.");
OffsetDateTime startDateTime = OffsetDateTime.parse("2019-03-11T15:00:00Z");
sharedShift.setStartDateTime(startDateTime);
OffsetDateTime endDateTime = OffsetDateTime.parse("2019-03-12T00:00:00Z");
sharedShift.setEndDateTime(endDateTime);
sharedShift.setTheme(ScheduleEntityTheme.Blue);
LinkedList<ShiftActivity> activities = new LinkedList<ShiftActivity>();
ShiftActivity shiftActivity = new ShiftActivity();
shiftActivity.setIsPaid(true);
OffsetDateTime startDateTime1 = OffsetDateTime.parse("2019-03-11T15:00:00Z");
shiftActivity.setStartDateTime(startDateTime1);
OffsetDateTime endDateTime1 = OffsetDateTime.parse("2019-03-11T15:15:00Z");
shiftActivity.setEndDateTime(endDateTime1);
shiftActivity.setCode("");
shiftActivity.setDisplayName("Lunch");
activities.add(shiftActivity);
sharedShift.setActivities(activities);
shift.setSharedShift(sharedShift);
ShiftItem draftShift = new ShiftItem();
draftShift.setDisplayName("Day shift");
draftShift.setNotes("Please do inventory as part of your shift.");
OffsetDateTime startDateTime2 = OffsetDateTime.parse("2019-03-11T15:00:00Z");
draftShift.setStartDateTime(startDateTime2);
OffsetDateTime endDateTime2 = OffsetDateTime.parse("2019-03-12T00:00:00Z");
draftShift.setEndDateTime(endDateTime2);
draftShift.setTheme(ScheduleEntityTheme.Blue);
LinkedList<ShiftActivity> activities1 = new LinkedList<ShiftActivity>();
ShiftActivity shiftActivity1 = new ShiftActivity();
shiftActivity1.setIsPaid(true);
OffsetDateTime startDateTime3 = OffsetDateTime.parse("2019-03-11T15:00:00Z");
shiftActivity1.setStartDateTime(startDateTime3);
OffsetDateTime endDateTime3 = OffsetDateTime.parse("2019-03-11T15:30:00Z");
shiftActivity1.setEndDateTime(endDateTime3);
shiftActivity1.setCode("");
shiftActivity1.setDisplayName("Lunch");
activities1.add(shiftActivity1);
draftShift.setActivities(activities1);
shift.setDraftShift(draftShift);
Shift result = graphClient.teams().byTeamId("{team-id}").schedule().shifts().post(shift);
const options = {
authProvider,
};
const client = Client.init(options);
const shift = {
id: 'SHFT_577b75d2-a927-48c0-a5d1-dc984894e7b8',
userId: 'c5d0c76b-80c4-481c-be50-923cd8d680a1',
schedulingGroupId: 'TAG_228940ed-ff84-4e25-b129-1b395cf78be0',
sharedShift: {
displayName: 'Day shift',
notes: 'Please do inventory as part of your shift.',
startDateTime: '2019-03-11T15:00:00Z',
endDateTime: '2019-03-12T00:00:00Z',
theme: 'blue',
activities: [
{
isPaid: true,
startDateTime: '2019-03-11T15:00:00Z',
endDateTime: '2019-03-11T15:15:00Z',
code: '',
displayName: 'Lunch'
}
]
},
draftShift: {
displayName: 'Day shift',
notes: 'Please do inventory as part of your shift.',
startDateTime: '2019-03-11T15:00:00Z',
endDateTime: '2019-03-12T00:00:00Z',
theme: 'blue',
activities: [
{
isPaid: true,
startDateTime: '2019-03-11T15:00:00Z',
endDateTime: '2019-03-11T15:30:00Z',
code: '',
displayName: 'Lunch'
}
]
}
};
await client.api('/teams/{teamId}/schedule/shifts')
.version('beta')
.post(shift);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\Shift;
use Microsoft\Graph\Beta\Generated\Models\ShiftItem;
use Microsoft\Graph\Beta\Generated\Models\ScheduleEntityTheme;
use Microsoft\Graph\Beta\Generated\Models\ShiftActivity;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Shift();
$requestBody->setId('SHFT_577b75d2-a927-48c0-a5d1-dc984894e7b8');
$requestBody->setUserId('c5d0c76b-80c4-481c-be50-923cd8d680a1');
$requestBody->setSchedulingGroupId('TAG_228940ed-ff84-4e25-b129-1b395cf78be0');
$sharedShift = new ShiftItem();
$sharedShift->setDisplayName('Day shift');
$sharedShift->setNotes('Please do inventory as part of your shift.');
$sharedShift->setStartDateTime(new \DateTime('2019-03-11T15:00:00Z'));
$sharedShift->setEndDateTime(new \DateTime('2019-03-12T00:00:00Z'));
$sharedShift->setTheme(new ScheduleEntityTheme('blue'));
$activitiesShiftActivity1 = new ShiftActivity();
$activitiesShiftActivity1->setIsPaid(true);
$activitiesShiftActivity1->setStartDateTime(new \DateTime('2019-03-11T15:00:00Z'));
$activitiesShiftActivity1->setEndDateTime(new \DateTime('2019-03-11T15:15:00Z'));
$activitiesShiftActivity1->setCode('');
$activitiesShiftActivity1->setDisplayName('Lunch');
$activitiesArray []= $activitiesShiftActivity1;
$sharedShift->setActivities($activitiesArray);
$requestBody->setSharedShift($sharedShift);
$draftShift = new ShiftItem();
$draftShift->setDisplayName('Day shift');
$draftShift->setNotes('Please do inventory as part of your shift.');
$draftShift->setStartDateTime(new \DateTime('2019-03-11T15:00:00Z'));
$draftShift->setEndDateTime(new \DateTime('2019-03-12T00:00:00Z'));
$draftShift->setTheme(new ScheduleEntityTheme('blue'));
$activitiesShiftActivity1 = new ShiftActivity();
$activitiesShiftActivity1->setIsPaid(true);
$activitiesShiftActivity1->setStartDateTime(new \DateTime('2019-03-11T15:00:00Z'));
$activitiesShiftActivity1->setEndDateTime(new \DateTime('2019-03-11T15:30:00Z'));
$activitiesShiftActivity1->setCode('');
$activitiesShiftActivity1->setDisplayName('Lunch');
$activitiesArray []= $activitiesShiftActivity1;
$draftShift->setActivities($activitiesArray);
$requestBody->setDraftShift($draftShift);
$result = $graphServiceClient->teams()->byTeamId('team-id')->schedule()->shifts()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Teams
$params = @{
id = "SHFT_577b75d2-a927-48c0-a5d1-dc984894e7b8"
userId = "c5d0c76b-80c4-481c-be50-923cd8d680a1"
schedulingGroupId = "TAG_228940ed-ff84-4e25-b129-1b395cf78be0"
sharedShift = @{
displayName = "Day shift"
notes = "Please do inventory as part of your shift."
startDateTime = [System.DateTime]::Parse("2019-03-11T15:00:00Z")
endDateTime = [System.DateTime]::Parse("2019-03-12T00:00:00Z")
theme = "blue"
activities = @(
@{
isPaid = $true
startDateTime = [System.DateTime]::Parse("2019-03-11T15:00:00Z")
endDateTime = [System.DateTime]::Parse("2019-03-11T15:15:00Z")
code = ""
displayName = "Lunch"
}
)
}
draftShift = @{
displayName = "Day shift"
notes = "Please do inventory as part of your shift."
startDateTime = [System.DateTime]::Parse("2019-03-11T15:00:00Z")
endDateTime = [System.DateTime]::Parse("2019-03-12T00:00:00Z")
theme = "blue"
activities = @(
@{
isPaid = $true
startDateTime = [System.DateTime]::Parse("2019-03-11T15:00:00Z")
endDateTime = [System.DateTime]::Parse("2019-03-11T15:30:00Z")
code = ""
displayName = "Lunch"
}
)
}
}
New-MgBetaTeamScheduleShift -TeamId $teamId -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.models.shift import Shift
from msgraph_beta.generated.models.shift_item import ShiftItem
from msgraph_beta.generated.models.schedule_entity_theme import ScheduleEntityTheme
from msgraph_beta.generated.models.shift_activity import ShiftActivity
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Shift(
id = "SHFT_577b75d2-a927-48c0-a5d1-dc984894e7b8",
user_id = "c5d0c76b-80c4-481c-be50-923cd8d680a1",
scheduling_group_id = "TAG_228940ed-ff84-4e25-b129-1b395cf78be0",
shared_shift = ShiftItem(
display_name = "Day shift",
notes = "Please do inventory as part of your shift.",
start_date_time = "2019-03-11T15:00:00Z",
end_date_time = "2019-03-12T00:00:00Z",
theme = ScheduleEntityTheme.Blue,
activities = [
ShiftActivity(
is_paid = True,
start_date_time = "2019-03-11T15:00:00Z",
end_date_time = "2019-03-11T15:15:00Z",
code = "",
display_name = "Lunch",
),
],
),
draft_shift = ShiftItem(
display_name = "Day shift",
notes = "Please do inventory as part of your shift.",
start_date_time = "2019-03-11T15:00:00Z",
end_date_time = "2019-03-12T00:00:00Z",
theme = ScheduleEntityTheme.Blue,
activities = [
ShiftActivity(
is_paid = True,
start_date_time = "2019-03-11T15:00:00Z",
end_date_time = "2019-03-11T15:30:00Z",
code = "",
display_name = "Lunch",
),
],
),
)
result = await graph_client.teams.by_team_id('team-id').schedule.shifts.post(request_body)
Respuesta
En el ejemplo siguiente se muestra la respuesta.
Nota: Se puede acortar el objeto de respuesta que se muestra aquí para mejorar la legibilidad.
HTTP/1.1 201 Created
Content-type: application/json
{
"id": "SHFT_577b75d2-a927-48c0-a5d1-dc984894e7b8",
"createdDateTime": "2019-03-14T04:32:51.451Z",
"lastModifiedDateTime": "2019-03-14T05:32:51.451Z",
"userId": "c5d0c76b-80c4-481c-be50-923cd8d680a1",
"schedulingGroupId": "TAG_228940ed-ff84-4e25-b129-1b395cf78be0",
"lastModifiedBy": {
"application": null,
"device": null,
"conversation": null,
"user": {
"id": "366c0b19-49b1-41b5-a03f-9f3887bd0ed8",
"displayName": "John Doe"
}
},
"sharedShift": {
"displayName": "Day shift",
"notes": "Please do inventory as part of your shift.",
"startDateTime": "2019-03-11T15:00:00Z",
"endDateTime": "2019-03-12T00:00:00Z",
"theme": "blue",
"activities": [
{
"isPaid": true,
"startDateTime": "2019-03-11T15:00:00Z",
"endDateTime": "2019-03-11T15:15:00Z",
"code": "",
"displayName": "Lunch"
}
]
},
"draftShift": {
"displayName": "Day shift",
"notes": "Please do inventory as part of your shift.",
"startDateTime": "2019-03-11T15:00:00Z",
"endDateTime": "2019-03-12T00:00:00Z",
"theme": "blue",
"activities": [
{
"isPaid": true,
"startDateTime": "2019-03-11T15:00:00Z",
"endDateTime": "2019-03-11T15:30:00Z",
"code": "",
"displayName": "Lunch"
}
]
}
}