cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Super User
Super User

Common Data Service - SendEmailFromTemplate String Errors

Hello everyone,

 

I am trying to send an email from a Flow by using the Common Data Service (Current Environment) Unbound Action SendEmailFromTemplate. I worked through all the other snags (except for attachments) and I can generate the email by using Postman to connect to the WebApi, but as soon as I try and use the connector in Flow, I get a string error.

 

Postman SendEmailFromTemplate.jpg

 

The only thing that I changed between the body I used in Postman, and the action in Flow, is to double escape the '@' in the Target object by adding another '@', otherwise Flow can't save because it tries to evaluate odata. (ERROR: Unable to parse template language expression 'odata.type': expected token 'LeftParenthesis' and actual 'Dot')

"@@odata.type": "Microsoft.Dynamics.CRM.email"

 

If I use Common Data Service (Current Environment) Unbound Action SendEmailFromTemplate in Flow, I get the following error:

An error occurred while validating input parameters: System.FormatException: Input string was not in a correct format.
at System.Text.StringBuilder.FormatError()
at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.Format(IFormatProvider provider, String format, Object[] args)
at Microsoft.Crm.CrmHttpException..ctor(HttpStatusCode statusCode, String message, Object[] args)
at Microsoft.Crm.Extensibility.OData.CrmEdmEntityReference.CreateCrmEdmEntityReference(Uri link, IEdmModel edmModel, CrmODataExecutionContext context, EntitySetSegment& entitySetSegment)
at Microsoft.Crm.Extensibility.ODataV4.ODataParameterReaderExtensions.TryReadFlowPrimitiveData(ODataParameterReader oDataParameterReader, ODataDeserializerContext readContext, CrmEdmEntityObject& result)
at Microsoft.Crm.Extensibility.ODataV4.ODataParameterReaderExtensions.TryReadFlowPrimitive(ODataParameterReader oDataParameterReader, ODataDeserializerContext readContext, CrmEdmEntityObject& result)
at Microsoft.Crm.Extensibility.ODataV4.CrmODataActionPayloadDeserializer.Read(ODataMessageReader messageReader, Type type, ODataDeserializerContext readContext)
at System.Web.OData.Formatter.ODataMediaTypeFormatter.ReadFromStream(Type type, Stream readStream, HttpContent content, IFormatterLogger formatterLogger)

 

Below is the JSON I am using in Regarding and Target:

Common Data Service Unbound Action SendEmailFromTemplate.jpg

 

 

{
        "contactid": "B8fe2ee9-9f33-ea11-a813-000d3a24c29d",
        "@odata.type": "Microsoft.Dynamics.CRM.contact"
}

 

 

 

{
        "subject": "",
        "description": "",
        "regardingobjectid_contact@odata.bind": "/contacts(b8fe2ee9-9f33-ea11-a813-000d3a24c29d)",
        "email_activity_parties": [{
            "partyid_systemuser@odata.bind": "/systemusers(fba8443b-6365-4ade-ab81-abe6c47cba3b)",
            "participationtypemask": 1
        }, {
            "partyid_contact@odata.bind": "/contacts(b8fe2ee9-9f33-ea11-a813-000d3a24c29d)",
            "participationtypemask": 2
        }],
        "@@odata.type": "Microsoft.Dynamics.CRM.email"
    }

 

 

Error.jpg

 

It almost feels like the connector isn't handing the properties correctly. If you look at the Flow run result, the Regarding object doesn't seem to render to JSON, and Flow also doesn't complain if I don't double escape the '@' before odata so the object isn't set as JSON, BUT the API is reading the data in regarding because if I remove the data from Regarding, the API comes back and says that is requires Regarding to be specified.

 

Any ideas would be appreciated.

 

Have a great day!

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Common Data Service - SendEmailFromTemplate String Errors

Ok, that was fun.

 

Turns out that 'Regarding' should be a query, and not JSON, even though JSON is what is required when hitting the Api from Postman.

2020-01-11_07-35-10.jpg

 

Either I am reading this wrong, or the documentation doesn't quite state this. It feels like the Unbound action in the Common Data Service (Current Environment) could be simplified quite a bit. The CDS connector doesn't even mention the SendEmailFromTemplate action.

https://docs.microsoft.com/en-us/connectors/commondataserviceforapps/#perform-an-unbound-action

 

 

The WebApi docs says that for both 'Target' and 'Regarding' the CRM entity is required, yet is doesn't feel like this is entirely true, if you look at the JSON that you have to wright for 'Target'.

https://docs.microsoft.com/en-us/dynamics365/customer-engagement/web-api/sendemailfromtemplate?view=...

SendEmailFromTemplate.jpg

 

Very happy that this is working now, but it could have been an easier process 🤔

 

Dawid van Heerden
Follow on Twitter: @davestechtips
Subscribe to YouTube: https://www.youtube.com/davestechtips?sub_confirmation=1
**If you found this reply helpful, please like it and mark this as the answer to close the topic and make it easier to find for other people with similar questions. 

View solution in original post

1 REPLY 1
Super User
Super User

Re: Common Data Service - SendEmailFromTemplate String Errors

Ok, that was fun.

 

Turns out that 'Regarding' should be a query, and not JSON, even though JSON is what is required when hitting the Api from Postman.

2020-01-11_07-35-10.jpg

 

Either I am reading this wrong, or the documentation doesn't quite state this. It feels like the Unbound action in the Common Data Service (Current Environment) could be simplified quite a bit. The CDS connector doesn't even mention the SendEmailFromTemplate action.

https://docs.microsoft.com/en-us/connectors/commondataserviceforapps/#perform-an-unbound-action

 

 

The WebApi docs says that for both 'Target' and 'Regarding' the CRM entity is required, yet is doesn't feel like this is entirely true, if you look at the JSON that you have to wright for 'Target'.

https://docs.microsoft.com/en-us/dynamics365/customer-engagement/web-api/sendemailfromtemplate?view=...

SendEmailFromTemplate.jpg

 

Very happy that this is working now, but it could have been an easier process 🤔

 

Dawid van Heerden
Follow on Twitter: @davestechtips
Subscribe to YouTube: https://www.youtube.com/davestechtips?sub_confirmation=1
**If you found this reply helpful, please like it and mark this as the answer to close the topic and make it easier to find for other people with similar questions. 

View solution in original post

Helpful resources

Announcements
firstImage

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Users online (5,311)