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?
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.
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:
Best Regards,
Bof
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.
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
WarrenBelz
146,660
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,999
Most Valuable Professional