Skip to main content

Notifications

Community site session details

Community site session details

Session Id : DQKxT1LT+znCF2luFnUwXu
Power Apps - Microsoft Dataverse
Answered

Send email using Web API from postman

Like (0) ShareShare
ReportReport
Posted on 27 Jan 2021 23:34:21 by 31

I want to make an HTTP POST request using Postman to create an email record in which the "To" field is a static email address.
I intend to use the "To" as an unresolvable field, meaning that the Web API should not attempt to find a system user or a team.

The request below doesn't work

 

 

HTTP POST [Organization URI]/api/data/v9.0/emails
Content-Type: application/json; charset=utf-8
OData-MaxVersion: 4.0
OData-Version: 4.0
Accept: application/json

{
 "subject": "test",
 "to": "staticemail@domain.com"
}

 

 

Also tried this but it didn't work

 

 

{
 "subject": "test",
 "to": [ { "addressused": "staticemail@domail.com", "participationtypemask": 2}]
}

 

 

 

What is the right way to create an email using HTTP requests?

Categories:
  • Verified answer
    Ahmad Anwar Profile Picture
    31 on 29 Jan 2021 at 19:01:21
    Re: Send email using Web API from postman

    I figured it out.

    The right json body should like this:

     

    {
     "subject": "test",
     "email_activity_parties": [
     {"addressused":"email@test.com", "participationtypemask":2}
     ]
    }

     

    This is a blog post on how to achieve it in Power Automate.

    The last step is to find the key name, so I got the key name "email_activity_parties" by using F12 and open Dynamics 365, created an email with a static email and inspect the HTTP request made from the browser.
    Now I got the last piece of the puzzle.

    Thanks for the help.

     

  • v-bofeng-msft Profile Picture
    on 29 Jan 2021 at 02:23:56
    Re: Send email using Web API from postman

    Hi @AhmadAnwar :

     'To' is a complex type column(polymorphic lookup) in email entity, you can't update it with text or array or object as its value.Its target value is the record in these entitys (account, contact, knowledgearticle, queue, systemuser, unresolvedaddress).Please refer to this link for detailed instructions.

     I haven't tested it specifically, but maybe you can update the'To' field in this way:

    EntitySetName(GUID)

    contacts(ContactID)

     Maybe this link will help you a lot:

    https://community.dynamics.com/365/b/linn-s-power-platform-notebook/posts/power-automate-how-to-set-lookup-field-value-in-common-data-service-current-environment-flow-connector

    Best Regards,

    Bof

  • Ahmad Anwar Profile Picture
    31 on 28 Jan 2021 at 17:36:34
    Re: Send email using Web API from postman

    Sorry for my vague question.

    What I want is to create an email record using the CDS Web API.
    The problem I have is setting/populating the "To" field with a static email.

    When I remove the "To" from body, the request works, but when I add it back I get this error 400 message:

    {
     "error": {
     "code": "0x0",
     "message": "An error occurred while validating input parameters: Microsoft.OData.ODataException: Does not support untyped value in non-open type.\r\n at System.Web.OData.Formatter.Deserialization.DeserializationHelpers.ApplyProperty(ODataProperty property, IEdmStructuredTypeReference resourceType, Object resource, ODataDeserializerProvider deserializerProvider, ODataDeserializerContext readContext)\r\n at System.Web.OData.Formatter.Deserialization.ODataResourceDeserializer.ApplyStructuralProperties(Object resource, ODataResourceWrapper resourceWrapper, IEdmStructuredTypeReference structuredType, ODataDeserializerContext readContext)\r\n at Microsoft.Crm.Extensibility.CrmODataEntityDeserializer.ApplyStructuralProperties(Object resource, ODataResourceWrapper resourceWrapper, IEdmStructuredTypeReference structuredType, ODataDeserializerContext readContext)\r\n at System.Web.OData.Formatter.Deserialization.ODataResourceDeserializer.ReadResource(ODataResourceWrapper resourceWrapper, IEdmStructuredTypeReference structuredType, ODataDeserializerContext readContext)\r\n at System.Web.OData.Formatter.ODataMediaTypeFormatter.ReadFromStream(Type type, Stream readStream, HttpContent content, IFormatterLogger formatterLogger)"
     }
    }

     
    I hope my question is clear now.

  • v-bofeng-msft Profile Picture
    on 28 Jan 2021 at 03:32:00
    Re: Send email using Web API from postman

    Hi @AhmadAnwar :

    Do you want to create an API to send mail through PostMan?

      Firstly,could you please check whether ’[Organization URI]/api/data/v9.0/emails’ provides the function of sending emails?

    As far as I know "[organization URI]/api/data/v9.0/emails" is the Entity Set Path of an entity named "email" in the CDS. I'm not sure if this is a coincidence.

       Secondly,I suggest you call Microsoft Graph to send emails, the related API is

    Post https://graph.microsoft.com/v1.0/me/sendMail

     In addition, you also need to get access token to use in your requests to the Graph API.

    Maybe this link will help you a lot:

    sending-email-office-365-using-postman-without-logging-in-from-browser 

      Thirdly,If you want to send emails in Canvas APP or Flow, then you can directly use the ready-made Office 365 Outlook connector.

      Finally,If you have any more questions about postman, I suggest you go to its official website for help.

     Hope this helps,

     Best Regards,

     Bof 

     

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,660 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,999 Most Valuable Professional

Leaderboard

Featured topics