错误:为microsoft.crm.sdk.data.services类型指定的属性名称"firstname"无效

use*_*412 2 c# wcf jquery dynamics-crm dynamics-crm-2011

使用CRM 2011 oData服务创建联系时出现此错误.

var newContact = Object();
newContact.firstname = Xrm.Page.getAttribute("ct_leadconversioncontactfirstname").getValue();
newContact.lastname = Xrm.Page.getAttribute("ct_leadconversioncontactlastname").getValue();
newContact.gendercode = Xrm.Page.getAttribute("ct_leadconversioncontactgender").getValue();
newContact.jobtitle = Xrm.Page.getAttribute("ct_leadconversioncontactjobtitle").getValue();
newContact.websiteurl = Xrm.Page.getAttribute("ct_leadconversioncontactwebsite").getValue();

var jsonContact = window.JSON.stringify(newContact);

$.ajax({
    async: false,
    type: "POST",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    data: jsonContact,
    url: methodUrl,
    beforeSend: function (XMLHttpRequest) {
        //ensures the results will be returned as JSON.
        XMLHttpRequest.setRequestHeader("Accept", "application/json");
    },
    success: successCallback,
    error: failedCallback
});
Run Code Online (Sandbox Code Playgroud)

Chr*_*ris 5

我从错误中猜出你的网址是错误的.

确保methodUrl参数类似于:

url: <your servuer url> /XRMServices/2011/OrganizationData.svc/ContactSet"
Run Code Online (Sandbox Code Playgroud)

因为看起来请求是说"我得到你发送的内容,但你发布的内容在对象上没有名字属性"

所以检查一下发布到 ContactSet