Dynamics CRM 365 WebApi 8.2 AddListMembersList method

Tags: , , ,



Is there any example how to call AddListMembersList? I tried with:

let data = {
       "MemberIds": [500aa55d-f0c2-e711-80ca-005056bb6cde, 500aa55d-f0c2-e711-80ca-005056bb6cd, 500aa55d-f0c2-e711-80ca-005056bb6cde]
};

http.post(this.baseUrl + 'lists(770aa55d-f0c2-e711-80ca-005056bb6cde)/Microsoft.Dynamics.CRM.AddListMembersList', data);

but I get error:

“error”:{ “code”:””,”message”:”Request message has unresolved parameters.”,”innererror”:{ “message”:”Request message has unresolved parameters.”,”type”:”Microsoft.Crm.CrmHttpException”,”stacktrace”:” bei Microsoft.Crm.Extensibility.OData.CrmODataRoutingConvention.SelectAction(ODataPath odataPath, HttpControllerContext controllerContext, ILookup`2 actionMap)rn bei System.Web.OData.Routing.ODataActionSelector.SelectAction(HttpControllerContext controllerContext)rn bei System.Web.Http.ApiController.ExecuteAsync(HttpControllerContext controllerContext, CancellationToken cancellationToken)rn bei System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext()”

Any advice?

Answer

Exact answer can be found here: http://butenko.pro/2018/03/01/how-to-add-records-to-marketing-list-using-webapi/

From link adjusted to my example:

var data = {
    List: {
        listid: "9DEE7D76-611D-E811-A95B-000D3A1087A0",
        "@odata.type": "Microsoft.Dynamics.CRM.list"
    },
    Members: [{
        accountid: "6785A521-A2C0-E711-A950-000D3A109280",
        "@odata.type": "Microsoft.Dynamics.CRM.account"
    },
    {
        accountid: "3653A521-A2C0-E711-A950-000D3A109280",
        "@odata.type": "Microsoft.Dynamics.CRM.account"
    }]
};

this.http.post(this.baseUrl + 'AddListMembersList', data);


Source: stackoverflow