Microsoft Graph API insert new ListItem Field Datetime gap to 8 hours

Viewed 379

When we try to insert a new item with a DateTime field in a List of Sharepoint through Microsoft Graph Api V1.0 or Beta version. The API return us it new item with 8 hours of gap.

We are using Microsoft-sdk-javascript, but i think that this is not the problem. When we update any item, we don't have this issue.

For insert the DateTime we use ISOString according to documentation.

 var data = { fields: {
                            Title: 'test',
                            Fecha: moment().utc().toISOString(),
                        }
                    }
                    var result = await graph.insertItemListBeta(accessToken, listTestId, data);

We return this gap of hours (8 hours)

enter image description here

Do you have a solution for this??

Thanks you in advanced.

We try this in Postman and we have the same result.

enter image description here

1 Answers

API ignores 'Z' char - UTC indicator. It looks like a bug )-:

    POST https://graph.microsoft.com/v1.0/sites/siteId/lists/listId/items
Content-Type: application/json
Authorization: Bearer token

{
  "fields": {
    "Title": "any title",
    "timestamp": "2021-06-22T12:00:00"
  }
}





Request:  "begin": "2000-01-01T00:00:00Z"
Response: "begin": "1999-12-31T16:00:00Z"
 -8h
 
 
Request:  "begin": "2021-06-22T12:00:00Z"
Response: "begin": "2021-06-22T05:00:00Z"   
 -7h
 
Request:  "begin": "2021-06-22T12:00:00"
Response: "begin": "2021-06-22T12:00:00Z"
 Ignores UTC - Z char ... 
Related