1.使用Post创建实体记录
代码如下
function CreateUsingWebAPI() {
var req = new XMLHttpreq()
var str = null;
debugger;
req.open("POST", encodeURI(Xrm.Page.context.getClientUrl() + "/api/data/v8.0/accounts"), true);
req.setreqHeader("Accept", "application/json");
req.setreqHeader("Content-Type", "application/json; CHARSET=utf-8");
req.setreqHeader("OData-MaxVersion", "4.0");//可以省略此行
req.setreqHeader("OData-Version", "4.0");//可以省略此行
req.send(JSON.stringify({
name: "Sample account",//文本类型
new_twooptions: true,//bool类型
new_money1: 1000,//货币类型
new_optionset: 1000,//选项集
new_date: new Date(),//日期
"new_lookup@odata.bind": "/accounts(D5957650-59A5-E711-80C5-AFF8F414EE97)"//查找类型
}));
req.onre