cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

V4CalendarPostItem Error: String was not recognized as a valid DateTime

Hello,

I try to add a new Event to a shared Office365 Group Calendar:

 

Set(
    CalendarCollection;
    Office365.CalendarGetTablesV2()
);;
Set(
    CalendarTable;
    CalendarCollection.value
);;

//UPDATE CALENDAR (READ OUT ID FROM OFFICE365 CALENDAR TABLE)
Office365.V4CalendarPostItem(
    "AAMkAGExZWRlNWNmLTc2NWItNGsdfsdfsdfsdFjMzZmN2EwMABGAAAAAABLIf73NEoOQ6NIwWqOnOtHBwBpemr64iz7SLWTPDFSDGsgdGSDGgHgJFhemr64iz7SLWTP8cWpqCVAABBWAF6AAA=";
    _requesterBalanceRecord.EmployeeName & " URL";
    DateTimeValue("2020-02-12T04:00:00");
    DateTimeValue("2020-02-13T16:00:00");
    DateTimeZone.Local
);;

 

 

From https://docs.microsoft.com/de-de/connectors/office365/#create-event-(v4) I get the information about the datatypes.

 

Start time of the event (example: '2017-08-29T04:00:00')

 

I try all kind of passing the datetime. (as string, as DateTimeValue and so on)

 

But executing the command always throw:

 

Error on "Office36S.V4CalendarPostItem": { 'status': 400, "message: "String was not recognized as a valid DateTime.\r\nclientRequestld: 1c18b7c7-77cc-4752-b392-de066bfebaa0", 'error':{ "message: "String was not recognized as a valid DateTime." }, "source": "office36S-weazconn-we-01.p.azurewebsites.net" }

 

Thankful for any response.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Helper I
Helper I

Re: V4CalendarPostItem Error: String was not recognized as a valid DateTime

I realized that approach with a custom Flow.

The Flow listen to a specific mail subject (URL) and convert the body content to json. The json values could used for the calendar event. This flow enable to create a calendar event for any Office365 account.

 

 

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "type": "String",
            "metadata": {
                "description": "Name of the logic app."
            }
        },
        "logicAppLocation": {
            "defaultValue": "[resourceGroup().location]",
            "allowedValues": ["eastasia", "southeastasia", "centralus", "eastus", "eastus2", "westus", "northcentralus", "southcentralus", "northeurope", "westeurope", "japanwest", "japaneast", "brazilsouth", "australiaeast", "australiasoutheast", "southindia", "centralindia", "westindia", "canadacentral", "canadaeast", "westcentralus", "westus2", "[resourceGroup().location]"],
            "type": "String",
            "metadata": {
                "description": "Location of the logic app."
            }
        },
        "office365_Connection_Name": {
            "defaultValue": "office365",
            "type": "String",
            "metadata": {
                "description": "Name of the connection."
            }
        }
    },
    "resources": [{
        "type": "Microsoft.Logic/workflows",
        "apiVersion": "2016-06-01",
        "name": "[parameters('logicAppName')]",
        "location": "[parameters('logicAppLocation')]",
        "dependsOn": ["[resourceId('Microsoft.Web/connections', parameters('office365_Connection_Name'))]"],
        "properties": {
            "state": "Disabled",
            "definition": {
                "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                "contentVersion": "1.0.0.0",
                "parameters": {
                    "$connections": {
                        "defaultValue": {},
                        "type": "Object"
                    },
                    "$authentication": {
                        "defaultValue": {},
                        "type": "SecureObject"
                    }
                },
                "triggers": {
                    "Bei_Eingang_einer_neuen_E-Mail_(V3)": {
                        "splitOn": "@triggerBody()?['value']",
                        "metadata": {
                            "flowSystemMetadata": {
                                "swaggerOperationId": "OnNewEmailV3"
                            }
                        },
                        "type": "ApiConnectionNotification",
                        "inputs": {
                            "host": {
                                "connection": {
                                    "name": "@parameters('$connections')['office365']['connectionId']"
                                }
                            },
                            "fetch": {
                                "queries": {
                                    "folderPath": "Inbox",
                                    "importance": "Any",
                                    "fetchOnlyWithAttachment": false,
                                    "includeAttachments": false,
                                    "subjectFilter": "URL"
                                },
                                "pathTemplate": {
                                    "template": "/v3/Mail/OnNewEmail"
                                },
                                "method": "get"
                            },
                            "subscribe": {
                                "queries": {
                                    "folderPath": "Inbox",
                                    "importance": "Any",
                                    "fetchOnlyWithAttachment": false
                                },
                                "body": {
                                    "NotificationUrl": "@{listCallbackUrl()}"
                                },
                                "pathTemplate": {
                                    "template": "/GraphMailSubscriptionPoke/$subscriptions"
                                },
                                "method": "post"
                            },
                            "authentication": "@parameters('$authentication')"
                        }
                    }
                },
                "actions": {
                    "Termin_erstellen_(V4)": {
                        "runAfter": {
                            "JSON_analysieren": ["Succeeded"]
                        },
                        "metadata": {
                            "flowSystemMetadata": {
                                "swaggerOperationId": "V4CalendarPostItem"
                            }
                        },
                        "type": "ApiConnection",
                        "inputs": {
                            "host": {
                                "connection": {
                                    "name": "@parameters('$connections')['office365']['connectionId']"
                                }
                            },
                            "method": "post",
                            "body": {
                                "subject": "@body('JSON_analysieren')?['Subject']",
                                "start": "@body('JSON_analysieren')?['Start']",
                                "end": "@body('JSON_analysieren')?['End']",
                                "timeZone": "(UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna",
                                "body": "TYPE: @{body('JSON_analysieren')?['Type']}\nAPPLICANT: @{body('JSON_analysieren')?['Applicant']}\nAPPROVER: @{body('JSON_analysieren')?['Approver']}\nSTART:  @{body('JSON_analysieren')?['Start']}\nEND:  @{body('JSON_analysieren')?['End']}",
                                "importance": "normal",
                                "isAllDay": false,
                                "recurrence": "none",
                                "isReminderOn": false,
                                "showAs": "free",
                                "responseRequested": false
                            },
                            "path": "/datasets/calendars/v4/tables/@{encodeURIComponent(encodeURIComponent('AAMkAGExZWRlNWNmLTc2NWItNGM3NS1hMzAwLTE4Y2FjMzZmN2EwMABGAAAAAABLIf73NEoOQ6NIwWqOnOtHBwBpemr64iz7SLWTP8cWpqCVAAAAAAEGAABpemr64iz7SLWTP8cWpqCVAAAAAGnsAAA='))}/items",
                            "authentication": "@parameters('$authentication')"
                        }
                    },
                    "JSON_analysieren": {
                        "runAfter": {},
                        "type": "ParseJson",
                        "inputs": {
                            "content": "@triggerBody()?['body']",
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "Subject": {
                                        "type": "string"
                                    },
                                    "Type": {
                                        "type": "string"
                                    },
                                    "Applicant": {
                                        "type": "string"
                                    },
                                    "Approver": {
                                        "type": "string"
                                    },
                                    "Start": {
                                        "type": "string"
                                    },
                                    "End": {
                                        "type": "string"
                                    }
                                }
                            }
                        }
                    }
                },
                "description": "Erzeugt ein Kalender Event nach Erhalt einer spezifischen Email."
            },
            "parameters": {
                "$connections": {
                    "value": {
                        "office365": {
                            "id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', parameters('logicAppLocation'), '/managedApis/', 'office365')]",
                            "connectionId": "[resourceId('Microsoft.Web/connections', parameters('office365_Connection_Name'))]",
                            "connectionName": "[parameters('office365_Connection_Name')]"
                        }
                    }
                }
            },
            "runtimeConfiguration": {
                "lifetime": {
                    "unit": "Day",
                    "count": 30
                },
                "collections": {
                    "maximumItemCount": 5000
                },
                "performanceProfile": {
                    "throttles": {
                        "mode": "Low"
                    }
                },
                "retryPolicy": {
                    "type": "Exponential",
                    "interval": "PT5M",
                    "count": 2,
                    "minimumInterval": "PT5M",
                    "maximumInterval": "PT1H"
                }
            }
        }
    }, {
        "type": "Microsoft.Web/connections",
        "apiVersion": "2016-06-01",
        "name": "[parameters('office365_Connection_Name')]",
        "location": "[parameters('logicAppLocation')]",
        "properties": {
            "api": {
                "id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', parameters('logicAppLocation'), '/managedApis/', 'office365')]"
            },
            "displayName": "[parameters('office365_Connection_Name')]"
        }
    }]
}

 

 

@v-siky-msft thanks for your help and have a happy new year. 🙂

View solution in original post

6 REPLIES 6
Highlighted
Community Support
Community Support

Re: V4CalendarPostItem Error: String was not recognized as a valid DateTime

Hi @Nusserdt ,

 

I have made a test on my side, please add the Office365 Outlook connection and change to use Office365Outlook.V4CalendarPostItem function. Please modify your codes as below.

 

Set(
    CalendarTable;
    Office365Outlook.CalendarGetTablesV2().value
);;

//UPDATE CALENDAR (READ OUT ID FROM OFFICE365 CALENDAR TABLE)
Office365Outlook.V4CalendarPostItem(
"AAMkAGExZWRlNWNmLTc2NWItNGsdfsdfsdfsdFjMzZmN2EwMABGAAAAAABLIf73NEoOQ6NIwWqOnOtHBwBpemr64iz7SLWTPDFSDGsgdGSDGgHgJFhemr64iz7SLWTP8cWpqCVAABBWAF6AAA=";
    _requesterBalanceRecord.EmployeeName & " URL";
    DateTimeValue("2020-02-12T04:00:00");
    DateTimeValue("2020-02-13T16:00:00");
    "(UTC) Coordinated Universal Time"
)

 

 Sik

Highlighted
Helper I
Helper I

Re: V4CalendarPostItem Error: String was not recognized as a valid DateTime

Hello @v-siky-msft,

 

I try your example, and it works fine! Thanks a lot.

 

Is there also a possibility to post a event in another calendar?

 

---

 

the problem is: in the LeaveRequest Template a manager have to approve a request. This is what we need but after approving we also need the the leave request event get postet inside the employees calendar. But this is not possible in that way because the manager account is logged in in that moment. Also interesting for us is to post the leave request in a global calendar, so all employees can the the leaves of there colleges. I try to configure a custom connector to solve this, but I give up frustrated. Is that a restriction for powerapps and it is not possible to archive?

Highlighted
Community Support
Community Support

Re: V4CalendarPostItem Error: String was not recognized as a valid DateTime

Hi @Nusserdt ,

 

You are right, it is not supported to get and post events in other tenants' calendar.

You can vote for this idea: Post an event to any user's calendar

if it is high voted there by other customers, it will be promising that Microsoft Product Team will take it into consideration when designing the next version in the future.

Sik

Highlighted
Helper I
Helper I

Re: V4CalendarPostItem Error: String was not recognized as a valid DateTime

@v-siky-msft thanks for your reply, I give my upvote. Considering that the post is older than 2 years, is it possible to create a calendar event by an email? I think of a rule based handling of emails with subject XXX contains specific data (DateStart, DateEnd) to convert it automated to a calendar event.

 

That could be a good workaround.

Highlighted
Helper I
Helper I

Re: V4CalendarPostItem Error: String was not recognized as a valid DateTime

I realized that approach with a custom Flow.

The Flow listen to a specific mail subject (URL) and convert the body content to json. The json values could used for the calendar event. This flow enable to create a calendar event for any Office365 account.

 

 

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "type": "String",
            "metadata": {
                "description": "Name of the logic app."
            }
        },
        "logicAppLocation": {
            "defaultValue": "[resourceGroup().location]",
            "allowedValues": ["eastasia", "southeastasia", "centralus", "eastus", "eastus2", "westus", "northcentralus", "southcentralus", "northeurope", "westeurope", "japanwest", "japaneast", "brazilsouth", "australiaeast", "australiasoutheast", "southindia", "centralindia", "westindia", "canadacentral", "canadaeast", "westcentralus", "westus2", "[resourceGroup().location]"],
            "type": "String",
            "metadata": {
                "description": "Location of the logic app."
            }
        },
        "office365_Connection_Name": {
            "defaultValue": "office365",
            "type": "String",
            "metadata": {
                "description": "Name of the connection."
            }
        }
    },
    "resources": [{
        "type": "Microsoft.Logic/workflows",
        "apiVersion": "2016-06-01",
        "name": "[parameters('logicAppName')]",
        "location": "[parameters('logicAppLocation')]",
        "dependsOn": ["[resourceId('Microsoft.Web/connections', parameters('office365_Connection_Name'))]"],
        "properties": {
            "state": "Disabled",
            "definition": {
                "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                "contentVersion": "1.0.0.0",
                "parameters": {
                    "$connections": {
                        "defaultValue": {},
                        "type": "Object"
                    },
                    "$authentication": {
                        "defaultValue": {},
                        "type": "SecureObject"
                    }
                },
                "triggers": {
                    "Bei_Eingang_einer_neuen_E-Mail_(V3)": {
                        "splitOn": "@triggerBody()?['value']",
                        "metadata": {
                            "flowSystemMetadata": {
                                "swaggerOperationId": "OnNewEmailV3"
                            }
                        },
                        "type": "ApiConnectionNotification",
                        "inputs": {
                            "host": {
                                "connection": {
                                    "name": "@parameters('$connections')['office365']['connectionId']"
                                }
                            },
                            "fetch": {
                                "queries": {
                                    "folderPath": "Inbox",
                                    "importance": "Any",
                                    "fetchOnlyWithAttachment": false,
                                    "includeAttachments": false,
                                    "subjectFilter": "URL"
                                },
                                "pathTemplate": {
                                    "template": "/v3/Mail/OnNewEmail"
                                },
                                "method": "get"
                            },
                            "subscribe": {
                                "queries": {
                                    "folderPath": "Inbox",
                                    "importance": "Any",
                                    "fetchOnlyWithAttachment": false
                                },
                                "body": {
                                    "NotificationUrl": "@{listCallbackUrl()}"
                                },
                                "pathTemplate": {
                                    "template": "/GraphMailSubscriptionPoke/$subscriptions"
                                },
                                "method": "post"
                            },
                            "authentication": "@parameters('$authentication')"
                        }
                    }
                },
                "actions": {
                    "Termin_erstellen_(V4)": {
                        "runAfter": {
                            "JSON_analysieren": ["Succeeded"]
                        },
                        "metadata": {
                            "flowSystemMetadata": {
                                "swaggerOperationId": "V4CalendarPostItem"
                            }
                        },
                        "type": "ApiConnection",
                        "inputs": {
                            "host": {
                                "connection": {
                                    "name": "@parameters('$connections')['office365']['connectionId']"
                                }
                            },
                            "method": "post",
                            "body": {
                                "subject": "@body('JSON_analysieren')?['Subject']",
                                "start": "@body('JSON_analysieren')?['Start']",
                                "end": "@body('JSON_analysieren')?['End']",
                                "timeZone": "(UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna",
                                "body": "TYPE: @{body('JSON_analysieren')?['Type']}\nAPPLICANT: @{body('JSON_analysieren')?['Applicant']}\nAPPROVER: @{body('JSON_analysieren')?['Approver']}\nSTART:  @{body('JSON_analysieren')?['Start']}\nEND:  @{body('JSON_analysieren')?['End']}",
                                "importance": "normal",
                                "isAllDay": false,
                                "recurrence": "none",
                                "isReminderOn": false,
                                "showAs": "free",
                                "responseRequested": false
                            },
                            "path": "/datasets/calendars/v4/tables/@{encodeURIComponent(encodeURIComponent('AAMkAGExZWRlNWNmLTc2NWItNGM3NS1hMzAwLTE4Y2FjMzZmN2EwMABGAAAAAABLIf73NEoOQ6NIwWqOnOtHBwBpemr64iz7SLWTP8cWpqCVAAAAAAEGAABpemr64iz7SLWTP8cWpqCVAAAAAGnsAAA='))}/items",
                            "authentication": "@parameters('$authentication')"
                        }
                    },
                    "JSON_analysieren": {
                        "runAfter": {},
                        "type": "ParseJson",
                        "inputs": {
                            "content": "@triggerBody()?['body']",
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "Subject": {
                                        "type": "string"
                                    },
                                    "Type": {
                                        "type": "string"
                                    },
                                    "Applicant": {
                                        "type": "string"
                                    },
                                    "Approver": {
                                        "type": "string"
                                    },
                                    "Start": {
                                        "type": "string"
                                    },
                                    "End": {
                                        "type": "string"
                                    }
                                }
                            }
                        }
                    }
                },
                "description": "Erzeugt ein Kalender Event nach Erhalt einer spezifischen Email."
            },
            "parameters": {
                "$connections": {
                    "value": {
                        "office365": {
                            "id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', parameters('logicAppLocation'), '/managedApis/', 'office365')]",
                            "connectionId": "[resourceId('Microsoft.Web/connections', parameters('office365_Connection_Name'))]",
                            "connectionName": "[parameters('office365_Connection_Name')]"
                        }
                    }
                }
            },
            "runtimeConfiguration": {
                "lifetime": {
                    "unit": "Day",
                    "count": 30
                },
                "collections": {
                    "maximumItemCount": 5000
                },
                "performanceProfile": {
                    "throttles": {
                        "mode": "Low"
                    }
                },
                "retryPolicy": {
                    "type": "Exponential",
                    "interval": "PT5M",
                    "count": 2,
                    "minimumInterval": "PT5M",
                    "maximumInterval": "PT1H"
                }
            }
        }
    }, {
        "type": "Microsoft.Web/connections",
        "apiVersion": "2016-06-01",
        "name": "[parameters('office365_Connection_Name')]",
        "location": "[parameters('logicAppLocation')]",
        "properties": {
            "api": {
                "id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', parameters('logicAppLocation'), '/managedApis/', 'office365')]"
            },
            "displayName": "[parameters('office365_Connection_Name')]"
        }
    }]
}

 

 

@v-siky-msft thanks for your help and have a happy new year. 🙂

View solution in original post

Highlighted
Advocate I
Advocate I

Re: V4CalendarPostItem Error: String was not recognized as a valid DateTime

Hi @Nusserdt, would it be possible for you to post a screenshot of your Flow please? I'd like to try and implement your solution but I'm not quite sure how to get started.

 

Thanks

Joel

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (6,697)