POST https://graph.microsoft.com/beta/teams/871dbd5c-3a6a-4392-bfe1-042452793a50/schedule/timeCards
Content-type: application/json
{
"onBehalfOfUserId":"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
{
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,
},
},
},
},
AdditionalData = new Dictionary<string, object>
{
{
"onBehalfOfUserId" , "a3601044-a1b5-438e-b742-f78d01d68a67"
},
},
};
// 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);
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
TimeCard timeCard = new TimeCard();
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);
HashMap<String, Object> additionalData = new HashMap<String, Object>();
additionalData.put("onBehalfOfUserId", "a3601044-a1b5-438e-b742-f78d01d68a67");
timeCard.setAdditionalData(additionalData);
TimeCard result = graphClient.teams().byTeamId("{team-id}").schedule().timeCards().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();
$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);
$additionalData = [
'onBehalfOfUserId' => 'a3601044-a1b5-438e-b742-f78d01d68a67',
];
$requestBody->setAdditionalData($additionalData);
$result = $graphServiceClient->teams()->byTeamId('team-id')->schedule()->timeCards()->post($requestBody)->wait();