Create Post with Dynamics CRM Web API

The Post object ( https://msdn.microsoft.com/en-us/library/mt607553.aspx ) cannot be created using the Dynamics CRM 2016 online API.

This payload should create a post on POST /api/data/v8.1/posts

 { "text": "Test Single Post", "source": 1, "type": 7 } 

(source 1 is an automatic post, type 7 is a status message)

But it returns:

 { "error": { "code":"", "message":"An unexpected error occurred.", "innererror" { "message":"An unexpected error occurred..." } } } 

Sending the same payload only with "text" does not work either.

Note that the Post object does not have unambiguous navigation properties ( https://msdn.microsoft.com/en-us/library/mt607553.aspx#bkmk_SingleValuedNavigationProperties ), which will allow me to set up a related object (contact, account, etc. )

For example, creating a Task object ( https://msdn.microsoft.com/en-us/library/mt607619.aspx ) works fine on POST /api/data/v8.1/tasks

 { "subject": "Test Single Task", "description": "Test One Description of Task", " regardingobjectid_contact_task@odata.bind ": "/contacts(<someguid>)", "scheduledend": "2016-07-21T12:11:19.4875892Z" } 

It seems to me that Post should expose something like regardingobjectid_contact_post@odata.bind , but it is not.

In context, this is how to create a message through the SOAP endpoint and SDK:

 var result = Client.getOrganizationService().Create(new Post { Text = post.text, RegardingObjectId = new EntityReference( entityName, Guid.Parse(post.regarding_guid) ) }); 

Does anyone have a working example of Post created via web API? Is this an omission in the Dynamics CRM API?

It does not seem to be indicated in the restrictions: https://msdn.microsoft.com/en-us/library/mt628816.aspx

UPDATE

It looks like the postregarding object is where the link should be created for the contact / account. This can be demonstrated by requesting:

 /posts?$filter=postregardingid/regardingobjectid_contact/contactid eq <someguid> 

However, deep insertion, for example, does not work:

 { "text":"sometext", "postregardingid": { " regardingobjectid_contact@odata.bind ":"/contacts(someguid)" } } 

Answer

Unable to create child entities in front of the parent.

+6
source share
1 answer

Nowhere is it mentioned that Post (activity feed) cannot be created using webapi. Actually, this is not indicated as a limitation of crm webapi, as you indicated.

Also when comparing, the _regardingobjectid_value post search property is different from the activitypointer . An unambiguous navigation property too.

Out of curiosity, my investigation went to the Partner - post_PostRegardings

The only thing that makes sense - postregarding is strictly internal use. This could be the cause of all this behavior. This is my theory for v8.2 today (August 12, 2017)

Description Represents which object the link to the activity stream belongs to. For internal use only.
object set path : [organization URI] /api/data/v8.2/postregardings
Base Type : crmbaseentity EntityType
Display name : User message Primary key : postregardingid

Link: https://msdn.microsoft.com/en-us/library/mt608103.aspx

0
source

All Articles