是否有任何示例如何致电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);
但我收到错误:
"错误":{ "代码":"","消息":"请求消息具有未解析的参数。"," innererror" :{ " message":"请求消息包含未解析的参数。"," type":" Microsoft.Crm.CrmHttpException","栈跟踪":" 北 Microsoft.Crm.Extensibility.OData.CrmODataRoutingConvention.SelectAction(ODataPath odataPath,HttpControllerContext controllerContext,ILookup`2 actionMap)\ r \ n bei System.Web.OData.Routing.ODataActionSelector.SelectAction(HttpControllerContext controllerContext)\ r \ n bei System.Web.Http.ApiController.ExecuteAsync(HttpControllerContext controllerContext,CancellationToken cancellationToken)\ r \ n bei System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext()"
有什么建议吗?
答案 0 :(得分: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));
答案 1 :(得分: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);