Cannot Convert a Primitive Value to the Expected Type 'Edm.DateTime'

Introduction

Often times working with PowerAutomate Date time format is a little tricky especially when working on updating a SharePoint date time column from Power Automate. SharePoint expects a special kind of format, which I recently faced an issue. Here I am using ‘send an http request’ using ‘POST’ update and got the below error in Power Automate run logs.

Cannot convert a primitive value to the expected type 'Edm.DateTime'

{
    "status": 400,
    "message": "Cannot convert a primitive value to the expected type 'Edm.DateTime'. See the inner exception for more details.\r\nclientRequestId: b3d17731-f034-4fc0-9a61-b421e9d5cbf5\r\nserviceRequestId: 2f3e05a1-807c-4000-ccde-ead528b54490",
    "source": "https://contosodev.sharepoint.com/teams/qaVinay/_api/lists/getbytitle('SurveyApplications')/items(1)",
    "errors": [
        "-1",
        "Microsoft.SharePoint.Client.InvalidClientQueryException"
    ]
}

The reason for this issue is SharePoint is not accepting the format of the Date Time field value from the JSON body.

Reason

Just a little background on the issue, when trying to update the SharePoint date time field it expects the date time in ISO 8601 format.

formatDateTime(utcNow(),'yyyy-MM-ddTHH:mm:ss')

When updating the body of the SharePoint send http request, the date should be in the ISO 8601 format. The body of the request is decorated in JSON as below. The key is to get the format of Year, Month, Day, Hours, Minutes, and seconds. In the below scenario, I am trying to add 365 days to the current date and update the value back in the SharePoint online list.

Compose- log current delegate

Below is the screenshot of the JSON body.

HTTP request to SharePoint

{

"SurveySubmitted":"true",
"AnniversaryDate":"@{outputs('Compose_-_Calculate_New_Anniversary')}"

}

You can learn more about the SharePoint http request and the date-time format options in PowerAutomate from the below references.

Conclusion

In this blog, you learn about the issue that was being faced when updating the SharePoint Date Time column and the correct format it expects when updating from Power Automate ‘Send http request’.

References