Timezone converted UTC in response, even if send in different time zone

Pratik Patil 0 Reputation points
2024-04-10T11:19:13.61+00:00

I am calling Microsoft graph api to create an event and send timezone e.g" Asia/Calcutta" but in response and in outlook calendar timezone set as "UTC"

payload: : {

    "subject": "DBEP",

    "body": {

        "contentType": "HTML",

        "content": "<div><a href="//salesprouat/calendar/?taskId=415511">View in SalesPro : DBEP</a></div>"

    },

    "start": {

        "dateTime": "2024-04-10T08:00:00.000Z",

        "timeZone": "Asia/Calcutta"

    },

    "end": {

    se:    "dateTime": "2024-04-10T08:15:00.000Z",

        "timeZone": "Asia/Calcutta"

    }

}

response:: {

    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('35deb0b3-deb8-48ca-8c8a-14470f76c63f')/calendar/events/$entity",

    "@odata.etag": "W/"zpXVhlr7vUaPMiv+gOOB4AAAWmD4BQ=="",

    "id": "AAMkAGVhODFkYTNhLWJlN2UtNDQ4Yi05YWU4LTNhYjJiOTI1YzIwNQBGAAAAAACFEN9owQ_WSaSTpFz0ElHUBwDOldWGWvu9Ro8yK-6A44HgAAAAAAENAADOldWGWvu9Ro8yK-6A44HgAABaafMLAAA=",

    "createdDateTime": "2024-04-10T05:47:31.8300722Z",

    "lastModifiedDateTime": "2024-04-10T05:47:31.8815325Z",

    "changeKey": "zpXVhlr7vUaPMiv+gOOB4AAAWmD4BQ==",

    "categories": [],

    "transactionId": null,

    "originalStartTimeZone": "UTC",

    "originalEndTimeZone": "UTC",

    "iCalUId": "040000008200E00074C5B7101A82E00800000000BD2C81940A8BDA0100000000000000001000000001341BF49A5A9E4182184D9961BFC311",

    "reminderMinutesBeforeStart": 15,

    "isReminderOn": true,

    "hasAttachments": false,

    "subject": "DBEP",

    "bodyPreview": "View in SalesPro : DBEP",

    "importance": "normal",

    "sensitivity": "normal",

    "isAllDay": false,

    "isCancelled": false,

    "isOrganizer": true,

    "responseRequested": true,

    "seriesMasterId": null,

    "showAs": "busy",

    "type": "singleInstance",

    "webLink": "https://outlook.office365.com/owa/?itemid=AAMkAGVhODFkYTNhLWJlN2UtNDQ4Yi05YWU4LTNhYjJiOTI1YzIwNQBGAAAAAACFEN9owQ%2BWSaSTpFz0ElHUBwDOldWGWvu9Ro8yK%2F6A44HgAAAAAAENAADOldWGWvu9Ro8yK%2F6A44HgAABaafMLAAA%3D&exvsurl=1&path=/calendar/item",

    "onlineMeetingUrl": null,

    "isOnlineMeeting": false,

    "onlineMeetingProvider": "unknown",

    "allowNewTimeProposals": true,

    "occurrenceId": null,

    "isDraft": false,

    "hideAttendees": false,

    "responseStatus": {

        "response": "organizer",

        "time": "0001-01-01T00:00:00Z"

    },

    "body": {

        "contentType": "html",

        "content": "<html>\r\n<head>\r\n<meta http-equiv="Content-Type" content="text/html; charset=utf-8">\r\n</head>\r\n<body>\r\n<div>[//salesprouat/calendar/?taskId=415511]View in SalesPro : DBEP</div>\r\n</body>\r\n</html>\r\n"

    },

    "start": {

        "dateTime": "2024-04-10T08:00:00.0000000",

        "timeZone": "UTC"

    },

    "end": {

        "dateTime": "2024-04-10T08:15:00.0000000",

        "timeZone": "UTC"

    },

    "location": {

        "displayName": "",

        "locationType": "default",

        "uniqueIdType": "unknown",

        "address": {},

        "coordinates": {}

    },

    "locations": [],

    "recurrence": null,

    "attendees": [],

    "organizer": {

        "emailAddress": {

            "name": "Pratik Patil (external)",

            "address": "Pratik.Patil@husqvarnagroup.com"

        }

    },

    "onlineMeeting": null

}

code javascpript:

function getOutLookApiRequestObj(taskObj) {

  const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
  
  let outlookTaskRequestObj = {
    "subject": taskObj.name,
    "body": {
      "contentType": "HTML",
      "content": taskObj && taskObj.comment || "",
    },
    "start": {
      "dateTime": taskObj.scheduled,
      "timeZone": timeZone
    },
    "end": {
      "dateTime": taskObj.planned_completion,
      "timeZone": timeZone
    },
  }
  return outlookTaskRequestOb
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,671 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. CharanyaB-MSFT 1,421 Reputation points Microsoft Vendor
    2024-04-11T21:10:33.79+00:00

    Hello @Pratik Patil,

    Thanks for reaching Microsoft.

    Use the Prefer: outlook.timezone request header to specify the time zone for the start and end times in the response. Please use the header as: Prefer: outlook.timezone="India Standard Time". Also specify the timezone property in the request body as "India Standard Time".

    Please refer the example from below documentation to create an event in the specified time zone:

    https://learn.microsoft.com/en-us/graph/api/user-post-events?view=graph-rest-1.0&tabs=http#example-1-create-an-event-in-the-specified-time-zone-and-assign-the-event-an-optional-transactionid-value

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.

    0 comments No comments