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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Create a Contact/Account Post with Web API

(1) ShareShare
ReportReport
Posted on by

To create a Task the request looks like this:

{
"subject" : "SomeSubject",
"description" : "SomeDescription",
"regardingobjectid_contact_task@odata.bind" : "/contacts(0000etc)"
}

Then POST it to /api/data/v8.1/tasks

However, creating a Post isn't so easy, as there is no direct relationship to a contact or account. We've got a postregardingid, but you can't create postregardings. https://msdn.microsoft.com/en-us/library/mt607553.aspx

Has anyone been able to create Posts with the Web API?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    Try to use CRMRestBuilder - it supports combination of WebApi and Create request - crmrestbuilder.codeplex.com

  • camt Profile Picture
    on at

    Thanks for that Andrii. That's a very cool tool!

    Unfortunately creating an entity against /posts results in an HTTP 500 Internal Server Error. Setting all the values (text, source, and type) or only a value for "text" causes this.

    The tool fails to generate any code if I set the "RegardingObjectId", which is what I really need. It doesn't show the additional dropdown to select the regarding entity.

    Unfortunately the tool also fails for Tasks too. It tries to populate RegardingObjectId instead of regardingobjectid_contact_task. "The property 'regardingobjectid' does not exist on type 'Microsoft.Dynamics.CRM.task'"

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Looks like you found a bug in this tool.

    That's weird. I tried different combinations and nothing worked properly. If you want to resolve your issue quickly you have 2 ways:

    1. Make it using SOAP call instead of REST. Here is good article about usage of SoapLogger from SDK package - www.powerobjects.com/.../microsoft-dynamics-crm-soap-logger-a-tool-that-can-greatly-simplify-writing-http-requests

    2. Create an Action that will retrieve input parameters and create a Post in a way similar to following - blogs.msdn.microsoft.com/.../how-to-create-a-post-with-mentions-using-workflow

    Here is how to call action using JavaScript and WebApi - www.c-sharpcorner.com/.../calling-custom-actions-using-web-api

    debajmecrm.com/.../invoke-your-custom-action-from-dynamics-crm-web-apidynamics-crm-2016

  • Verified answer
    camt Profile Picture
    on at

    Excellent suggestions Andrii. Thank you.

    I've been advised by MS to move off SOAP (I have a completely working SDK solution). There are intermittent connection problems with the SOAP discovery service to Canada. Web API connects consistently however.

    SOAP with the SDK is roughly this in case anyone is interested:

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


    A custom action may be the only solution if this is an legitimate omission. I will pursue with support and update here.

  • camt Profile Picture
    on at

    I don't think this is a bug with the tool. Rather I can't seem to create a Post with Web API at all.

    POST to /api/data/v8.1/posts

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


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

    Returns:

    {
        "error":
        {
            "code":"",
            "message":"An unexpected error occurred.",
            "innererror"
            {
                "message":"An unexpected error occurred..."
            }
        }
    }
  • Community Member Profile Picture
    on at

    did you get solution for this? please let me know

  • Community Member Profile Picture
    on at

    I'm having the same problem, also can't create a new relationship 1:N between my entity and Posts

    {
    
        "text": "Sample Text",
    
        "regardingobjectid_request@odata.bind": "/requests(000000000)",
    
        "type": 4,
    
        "source": 2
    
    }

    Error:

    An undeclared property 'regardingobjectid_request' which only has property annotations in the payload but no property value was found in the payload. In OData, only declared navigation properties and declared named streams can be represented as properties without values.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans