0

有没有如何调用的例子AddListMembersList?我试过:

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);

但我得到错误:

"error":{ "code":"","message":"请求消息有未解析的参数。","innererror":{ "message":"请求消息有未解析的参数。","type":"Microsoft. Crm.CrmHttpException","stacktrace":" 北 Microsoft.Crm.Extensibility.OData.CrmODataRoutingConvention.SelectAction(ODataPath odataPath, HttpControllerContext controllerContext, ILookup`2 actionMap)\r\n 北 System.Web.OData.Routing.ODataActionSelector.SelectAction (HttpControllerContext controllerContext)\r\n 北 System.Web.Http.ApiController.ExecuteAsync(HttpControllerContext controllerContext, CancellationTokencancellationToken)\r\n 北 System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext()"

有什么建议吗?

4

2 回答 2

1

您正在尝试调用一个动作 - AddListMembersList。语法如下:

/api/data/v8.2/AddListMembersList

我建议您使用CRMRestBuilder来玩、测试和理解。

var parameters = {};
var list = {};
list.listid = "00000000-0000-0000-0000-000000000000";
list["@odata.type"] = "Microsoft.Dynamics.CRM.list";
parameters.List = list;
var members1 = {};
members1.contactid = "00000000-0000-0000-0000-000000000000";
members1["@odata.type"] = "Microsoft.Dynamics.CRM.contact";
parameters.Members = [members1];

var req = new XMLHttpRequest();
req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/AddListMembersList", true);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function() {
    if (this.readyState === 4) {
        req.onreadystatechange = null;
        if (this.status === 204) {
            //Success - No Return Data - Do Something
        } else {
            Xrm.Utility.alertDialog(this.statusText);
        }
    }
};
req.send(JSON.stringify(parameters));
于 2018-03-01T16:01:24.307 回答
1

可以在这里找到确切的答案:http: //butenko.pro/2018/03/01/how-to-add-records-to-marketing-list-using-webapi/

从链接调整为我的示例:

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);
于 2018-03-05T12:46:43.860 回答