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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Common Data Service - ...
Power Automate
Answered

Common Data Service - SendEmailFromTemplate String Errors

(0) ShareShare
ReportReport
Posted on by 1,346

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!

 

 

 

Categories:
  • Verified answer
    Dawidvh Profile Picture
    1,346 on at

    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=dynamics-ce-odata-9

    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. 

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 321 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 244

#3
Henil Profile Picture

Henil 102

Last 30 days Overall leaderboard