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.
Cree una instancia de timeCard en una programación.
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) |
Schedule.ReadWrite.All |
No disponible. |
Delegado (cuenta personal de Microsoft) |
No admitida. |
No admitida. |
Aplicación |
Schedule.ReadWrite.All |
No disponible. |
Solicitud HTTP
POST /teams/{teamId}/schedule/timeCards
Encabezado |
Valor |
Authorization |
{token} de portador. Obligatorio. Obtenga más información sobre la autenticación y la autorización. |
Tipo de contenido |
application/json. Obligatorio. |
MS-APP-ACTS-AS (en desuso) |
Un identificador de usuario (GUID). Solo se requiere 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 tokens de aplicación. |
Cuerpo de la solicitud
Proporcione el nuevo objeto timeCard en el cuerpo de la solicitud para este método.
Respuesta
Si se ejecuta correctamente, este método devuelve un 201 Created
código de respuesta y un objeto timeCard en el cuerpo de la respuesta.
Ejemplo
Solicitud
En el ejemplo siguiente se muestra la solicitud.
POST https://graph.microsoft.com/beta/teams/871dbd5c-3a6a-4392-bfe1-042452793a50/schedule/timeCards
Content-type: application/json
{
"userId":"a3601044-a1b5-438e-b742-f78d01d68a67",
"clockInEvent":{
"dateTime":"2019-03-18T00:00:00.000Z",
"isAtApprovedLocation":true,
"notes": {
"content": "Started late due to traffic in CA 237",
"contentType": "text"
},
},
"notes":{
"content": "8 To 5 Inventory management",
"contentType": "text"
},
"breaks":[
{
"breakId": "string",
"notes":{
"content": "Lunch break",
"contentType": "text"
},
"start":{
"dateTime":"2019-03-18T02:00:00.000Z",
"isAtApprovedLocation":true,
"notes": {
"content": "Reduced break to make up for lost time",
"contentType": "text"
},
}
}
]
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new TimeCard
{
UserId = "a3601044-a1b5-438e-b742-f78d01d68a67",
ClockInEvent = new TimeCardEvent
{
DateTime = DateTimeOffset.Parse("2019-03-18T00:00:00.000Z"),
IsAtApprovedLocation = true,
Notes = new ItemBody
{
Content = "Started late due to traffic in CA 237",
ContentType = BodyType.Text,
},
},
Notes = new ItemBody
{
Content = "8 To 5 Inventory management",
ContentType = BodyType.Text,
},
Breaks = new List<TimeCardBreak>
{
new TimeCardBreak
{
BreakId = "string",
Notes = new ItemBody
{
Content = "Lunch break",
ContentType = BodyType.Text,
},
Start = new TimeCardEvent
{
DateTime = DateTimeOffset.Parse("2019-03-18T02:00:00.000Z"),
IsAtApprovedLocation = true,
Notes = new ItemBody
{
Content = "Reduced break to make up for lost time",
ContentType = BodyType.Text,
},
},
},
},
};
// 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.TimeCards.PostAsync(requestBody);
mgc-beta teams schedule time-cards create --team-id {team-id} --body '{\
"userId":"a3601044-a1b5-438e-b742-f78d01d68a67",\
"clockInEvent":{\
"dateTime":"2019-03-18T00:00:00.000Z",\
"isAtApprovedLocation":true,\
"notes": {\
"content": "Started late due to traffic in CA 237",\
"contentType": "text"\
},\
},\
"notes":{\
"content": "8 To 5 Inventory management",\
"contentType": "text"\
},\
"breaks":[\
{\
"breakId": "string",\
"notes":{\
"content": "Lunch break",\
"contentType": "text"\
},\
"start":{\
"dateTime":"2019-03-18T02:00:00.000Z",\
"isAtApprovedLocation":true,\
"notes": {\
"content": "Reduced break to make up for lost time",\
"contentType": "text"\
},\
}\
}\
]\
}\
'
// 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.NewTimeCard()
userId := "a3601044-a1b5-438e-b742-f78d01d68a67"
requestBody.SetUserId(&userId)
clockInEvent := graphmodels.NewTimeCardEvent()
dateTime , err := time.Parse(time.RFC3339, "2019-03-18T00:00:00.000Z")
clockInEvent.SetDateTime(&dateTime)
isAtApprovedLocation := true
clockInEvent.SetIsAtApprovedLocation(&isAtApprovedLocation)
notes := graphmodels.NewItemBody()
content := "Started late due to traffic in CA 237"
notes.SetContent(&content)
contentType := graphmodels.TEXT_BODYTYPE
notes.SetContentType(&contentType)
clockInEvent.SetNotes(notes)
requestBody.SetClockInEvent(clockInEvent)
notes := graphmodels.NewItemBody()
content := "8 To 5 Inventory management"
notes.SetContent(&content)
contentType := graphmodels.TEXT_BODYTYPE
notes.SetContentType(&contentType)
requestBody.SetNotes(notes)
timeCardBreak := graphmodels.NewTimeCardBreak()
breakId := "string"
timeCardBreak.SetBreakId(&breakId)
notes := graphmodels.NewItemBody()
content := "Lunch break"
notes.SetContent(&content)
contentType := graphmodels.TEXT_BODYTYPE
notes.SetContentType(&contentType)
timeCardBreak.SetNotes(notes)
start := graphmodels.NewTimeCardEvent()
dateTime , err := time.Parse(time.RFC3339, "2019-03-18T02:00:00.000Z")
start.SetDateTime(&dateTime)
isAtApprovedLocation := true
start.SetIsAtApprovedLocation(&isAtApprovedLocation)
notes := graphmodels.NewItemBody()
content := "Reduced break to make up for lost time"
notes.SetContent(&content)
contentType := graphmodels.TEXT_BODYTYPE
notes.SetContentType(&contentType)
start.SetNotes(notes)
timeCardBreak.SetStart(start)
breaks := []graphmodels.TimeCardBreakable {
timeCardBreak,
}
requestBody.SetBreaks(breaks)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
timeCards, err := graphClient.Teams().ByTeamId("team-id").Schedule().TimeCards().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
TimeCard timeCard = new TimeCard();
timeCard.setUserId("a3601044-a1b5-438e-b742-f78d01d68a67");
TimeCardEvent clockInEvent = new TimeCardEvent();
OffsetDateTime dateTime = OffsetDateTime.parse("2019-03-18T00:00:00.000Z");
clockInEvent.setDateTime(dateTime);
clockInEvent.setIsAtApprovedLocation(true);
ItemBody notes = new ItemBody();
notes.setContent("Started late due to traffic in CA 237");
notes.setContentType(BodyType.Text);
clockInEvent.setNotes(notes);
timeCard.setClockInEvent(clockInEvent);
ItemBody notes1 = new ItemBody();
notes1.setContent("8 To 5 Inventory management");
notes1.setContentType(BodyType.Text);
timeCard.setNotes(notes1);
LinkedList<TimeCardBreak> breaks = new LinkedList<TimeCardBreak>();
TimeCardBreak timeCardBreak = new TimeCardBreak();
timeCardBreak.setBreakId("string");
ItemBody notes2 = new ItemBody();
notes2.setContent("Lunch break");
notes2.setContentType(BodyType.Text);
timeCardBreak.setNotes(notes2);
TimeCardEvent start = new TimeCardEvent();
OffsetDateTime dateTime1 = OffsetDateTime.parse("2019-03-18T02:00:00.000Z");
start.setDateTime(dateTime1);
start.setIsAtApprovedLocation(true);
ItemBody notes3 = new ItemBody();
notes3.setContent("Reduced break to make up for lost time");
notes3.setContentType(BodyType.Text);
start.setNotes(notes3);
timeCardBreak.setStart(start);
breaks.add(timeCardBreak);
timeCard.setBreaks(breaks);
TimeCard result = graphClient.teams().byTeamId("{team-id}").schedule().timeCards().post(timeCard);
const options = {
authProvider,
};
const client = Client.init(options);
const timeCard = {
userId: 'a3601044-a1b5-438e-b742-f78d01d68a67',
clockInEvent: {
dateTime: '2019-03-18T00:00:00.000Z',
isAtApprovedLocation: true,
notes: {
content: 'Started late due to traffic in CA 237',
contentType: 'text'
},
},
notes: {
content: '8 To 5 Inventory management',
contentType: 'text'
},
breaks: [
{
breakId: 'string',
notes: {
content: 'Lunch break',
contentType: 'text'
},
start: {
dateTime: '2019-03-18T02:00:00.000Z',
isAtApprovedLocation: true,
notes: {
content: 'Reduced break to make up for lost time',
contentType: 'text'
},
}
}
]
};
await client.api('/teams/871dbd5c-3a6a-4392-bfe1-042452793a50/schedule/timeCards')
.version('beta')
.post(timeCard);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\TimeCard;
use Microsoft\Graph\Beta\Generated\Models\TimeCardEvent;
use Microsoft\Graph\Beta\Generated\Models\ItemBody;
use Microsoft\Graph\Beta\Generated\Models\BodyType;
use Microsoft\Graph\Beta\Generated\Models\TimeCardBreak;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new TimeCard();
$requestBody->setUserId('a3601044-a1b5-438e-b742-f78d01d68a67');
$clockInEvent = new TimeCardEvent();
$clockInEvent->setDateTime(new \DateTime('2019-03-18T00:00:00.000Z'));
$clockInEvent->setIsAtApprovedLocation(true);
$clockInEventNotes = new ItemBody();
$clockInEventNotes->setContent('Started late due to traffic in CA 237');
$clockInEventNotes->setContentType(new BodyType('text'));
$clockInEvent->setNotes($clockInEventNotes);
$requestBody->setClockInEvent($clockInEvent);
$notes = new ItemBody();
$notes->setContent('8 To 5 Inventory management');
$notes->setContentType(new BodyType('text'));
$requestBody->setNotes($notes);
$breaksTimeCardBreak1 = new TimeCardBreak();
$breaksTimeCardBreak1->setBreakId('string');
$breaksTimeCardBreak1Notes = new ItemBody();
$breaksTimeCardBreak1Notes->setContent('Lunch break');
$breaksTimeCardBreak1Notes->setContentType(new BodyType('text'));
$breaksTimeCardBreak1->setNotes($breaksTimeCardBreak1Notes);
$breaksTimeCardBreak1Start = new TimeCardEvent();
$breaksTimeCardBreak1Start->setDateTime(new \DateTime('2019-03-18T02:00:00.000Z'));
$breaksTimeCardBreak1Start->setIsAtApprovedLocation(true);
$breaksTimeCardBreak1StartNotes = new ItemBody();
$breaksTimeCardBreak1StartNotes->setContent('Reduced break to make up for lost time');
$breaksTimeCardBreak1StartNotes->setContentType(new BodyType('text'));
$breaksTimeCardBreak1Start->setNotes($breaksTimeCardBreak1StartNotes);
$breaksTimeCardBreak1->setStart($breaksTimeCardBreak1Start);
$breaksArray []= $breaksTimeCardBreak1;
$requestBody->setBreaks($breaksArray);
$result = $graphServiceClient->teams()->byTeamId('team-id')->schedule()->timeCards()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Teams
$params = @{
userId = "a3601044-a1b5-438e-b742-f78d01d68a67"
clockInEvent = @{
dateTime = [System.DateTime]::Parse("2019-03-18T00:00:00.000Z")
isAtApprovedLocation = $true
notes = @{
content = "Started late due to traffic in CA 237"
contentType = "text"
}
}
notes = @{
content = "8 To 5 Inventory management"
contentType = "text"
}
breaks = @(
@{
breakId = "string"
notes = @{
content = "Lunch break"
contentType = "text"
}
start = @{
dateTime = [System.DateTime]::Parse("2019-03-18T02:00:00.000Z")
isAtApprovedLocation = $true
notes = @{
content = "Reduced break to make up for lost time"
contentType = "text"
}
}
}
)
}
New-MgBetaTeamScheduleTimeCard -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.time_card import TimeCard
from msgraph_beta.generated.models.time_card_event import TimeCardEvent
from msgraph_beta.generated.models.item_body import ItemBody
from msgraph_beta.generated.models.body_type import BodyType
from msgraph_beta.generated.models.time_card_break import TimeCardBreak
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = TimeCard(
user_id = "a3601044-a1b5-438e-b742-f78d01d68a67",
clock_in_event = TimeCardEvent(
date_time = "2019-03-18T00:00:00.000Z",
is_at_approved_location = True,
notes = ItemBody(
content = "Started late due to traffic in CA 237",
content_type = BodyType.Text,
),
),
notes = ItemBody(
content = "8 To 5 Inventory management",
content_type = BodyType.Text,
),
breaks = [
TimeCardBreak(
break_id = "string",
notes = ItemBody(
content = "Lunch break",
content_type = BodyType.Text,
),
start = TimeCardEvent(
date_time = "2019-03-18T02:00:00.000Z",
is_at_approved_location = True,
notes = ItemBody(
content = "Reduced break to make up for lost time",
content_type = BodyType.Text,
),
),
),
],
)
result = await graph_client.teams.by_team_id('team-id').schedule.time_cards.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": "3895809b-a618-4c0d-86a0-d42b25b7d74f",
"userId": "a3601044-a1b5-438e-b742-f78d01d68a67",
"createdDateTime": "2019-03-18T00:00:00.000Z",
"createdBy": {
"user": {
"id": "a3601044-a1b5-438e-b742-f78d01d68a67",
"displayName": "Dwight Schrute"
}
},
"lastModifiedDateTime": "2019-03-18T00:00:00.000Z",
"lastModifiedBy": {
"user": {
"id": "a3601044-a1b5-438e-b742-f78d01d68a67",
"displayName": "Dwight Schrute"
}
},
"state": "onBreak",
"confirmationStatus": "notConfirmed",
"originalEntry": {
"clockInEvent": {
"dateTime": "2019-03-18T00:00:00.000Z",
"atApprovedLocation": true,
"isAtApprovedLocation": true,
"notes": {
"content": "Started late due to traffic in CA 237",
"contentType": "text"
}
},
"clockOutEvent": null,
"breaks": [
{
"breakId": "string",
"notes": {
"content": "Lunch break",
"contentType": "text"
},
"start": {
"dateTime": "2019-03-18T02:00:00.000Z",
"atApprovedLocation": true,
"isAtApprovedLocation": true,
"notes": {
"content": "Reduced break to make up for lost time",
"contentType": "text"
}
},
"end": null
}
]
},
"clockInEvent": {
"dateTime": "2019-03-18T00:00:00.000Z",
"atApprovedLocation": true,
"isAtApprovedLocation": true,
"notes": {
"content": "Started late due to traffic in CA 237",
"contentType": "text"
}
},
"clockOutEvent": null,
"notes": {
"content": "8 To 5 Inventory management",
"contentType": "text"
},
"breaks": [
{
"breakId": "string",
"notes": {
"content": "Lunch break",
"contentType": "text"
},
"start": {
"dateTime": "2019-03-18T02:00:00.000Z",
"atApprovedLocation": true,
"isAtApprovedLocation": true,
"notes": {
"content": "Reduced break to make up for lost time",
"contentType": "text"
}
},
"end": null
}
]
}