web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Unanswered

Business Central, Power Apps, Custom Connector "Cannot convert the literal '9/10/2021 12:00 AM' to the expected type 'Edm.DateTimeOffset', in Power Apps > Swagger Editor.

(0) ShareShare
ReportReport
Posted on by 20

Hello

I'm getting the below error in a Power Apps custom connector, I'm trying in Power Apps > Swagger Editor.

"Cannot convert the literal '9/10/2021 12:00 AM' to the expected type 'Edm.DateTimeOffset'

How should I pass values to DateTime and Date fields

Body -

{
"Client_Name": "From Postman",
"Created": "2021-09-10T00:00:00Z",
"CreatedBy": "ananda",
"Due_Date": "20211011D",
"Email": "spadmin@trygen1.onmicrosoft.com",
"ID": 0,
"Modified": "string",
"ModifiedBy": "string",
"Nationality": "string",
"Phone": "string",
"Progress": "string",
"Sprache": "string",
"Status": "string",
"Worth": "string"
}

"Cannot convert the literal '20211011D' to the expected type 'Edm.Date'.  

What will be the correct format for DateTime and Date fields.?

Please help.

Thank you

I have the same question (0)
  • ASTRI Profile Picture
    20 on at
    RE: Business Central, Power Apps, Custom Connector "Cannot convert the literal '9/10/2021 12:00 AM' to the expected type 'Edm.DateTimeOffset', in Power Apps > Swagger Editor.

    Thank you Josh, I've tried the same value,, not worked.

    My inputs

    {

     "Client_Name": "From Swagger",

     "Created": "2021-09-11T19:19:24.9646638Z",

     "CreatedBy": "Ananda Sanyal",

     "Due_Date": "2021-10-12",

     "Email": "string",

     "ID": 4,

     "Modified": "string",

     "ModifiedBy": "string",

     "Nationality": "string",

     "Phone": "string",

     "Progress": "string",

     "Sprache": "string",

     "Status": "string",

     "Worth": "string"

    }

    Server response

    Errors: 400

    {

     "error": {

       "code": "BadRequest",

       "message": "Cannot convert the literal 'string' to the expected type 'Edm.DateTimeOffset'.  CorrelationId:  bfad1601-4f2b-4182-aedc-dee86f1a80b5."

     }

    }

    Some thing is missing, As from Business Central, can add data.

    Thank you once again.

  • JAngle Profile Picture
    113 on at
    RE: Business Central, Power Apps, Custom Connector "Cannot convert the literal '9/10/2021 12:00 AM' to the expected type 'Edm.DateTimeOffset', in Power Apps > Swagger Editor.

    Try this as a value: “datetime”: “2021-09-11T19:19:24.9646638Z"

    To get this example output I used the date time connector in power automate

  • ASTRI Profile Picture
    20 on at
    RE: Business Central, Power Apps, Custom Connector "Cannot convert the literal '9/10/2021 12:00 AM' to the expected type 'Edm.DateTimeOffset', in Power Apps > Swagger Editor.

    I've developed the custom table, extension, which includes api page, works as usual in Business Central, These 2 are not system fields. I want to connect this from power app.

    The Get action is working as expected, Getting this error in Post, and assuming same will happen in Patch.

    APIPage contains -

    field(created; Rec.Created)

                   {

                       Caption = 'Created';

                   }

    field(dueDate; Rec.Due_Date)

                   {

                       Caption = 'Due';

                   }

    How you handle any date and datetime fields in connector?

    What values should be for these fields in swagger to test the connector?

    Thank you

  • JAngle Profile Picture
    113 on at
    RE: Business Central, Power Apps, Custom Connector "Cannot convert the literal '9/10/2021 12:00 AM' to the expected type 'Edm.DateTimeOffset', in Power Apps > Swagger Editor.

    Are those fields you need to set in the json body. Have you produced a custom connector for a new api page? If so just have the page set the value instead. System fields like that one typically get set by the database anyway

  • ASTRI Profile Picture
    20 on at
    RE: Business Central, Power Apps, Custom Connector "Cannot convert the literal '9/10/2021 12:00 AM' to the expected type 'Edm.DateTimeOffset', in Power Apps > Swagger Editor.

    Thank you Josh

    My body looks like below -

    {

     "Client_Name": "From Swagger",

     "Created": "2021-09-11", (DateTime field)

     "CreatedBy": "Ananda Sanyal",

     "Due_Date": "2021-10-12", (Date field)

     "Email": "string",

     "ID": 4,

     "Modified": "string",

     "ModifiedBy": "string",

     "Nationality": "string",

     "Phone": "string",

     "Progress": "string",

     "Sprache": "string",

     "Status": "string",

     "Worth": "string"

    }

    Error - 

    {
    "error": { "code": "BadRequest", "message": "Cannot convert the literal 'string' to the expected type 'Edm.DateTimeOffset'. CorrelationId: 121f6b84-a854-414d-a4a6-f5dbdf3f04eb." } }

    What values should I pass there?

    Thank you once again.

    ananda

  • JAngle Profile Picture
    113 on at
    RE: Business Central, Power Apps, Custom Connector "Cannot convert the literal '9/10/2021 12:00 AM' to the expected type 'Edm.DateTimeOffset', in Power Apps > Swagger Editor.

    UTC value expected if it is edm.datetimeoffset: docs.microsoft.com/.../converting-between-datetime-and-offset

    Edm.date looks like this statement is the suggestion: OData Library defines one struct to hold the value of Edm.Date (Format: YYYY-MM-DD). So you’re missing characters to break up the date with “-“

    docs.microsoft.com/.../date-timeofday-with-entity-framework

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 2,678 Super User 2025 Season 2

#2
Sumit Singh Profile Picture

Sumit Singh 2,635

#3
Jeffrey Bulanadi Profile Picture

Jeffrey Bulanadi 2,210

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans