2011-12-14 19 views
2

使用CRM 2011 oData服务创建联系人时出现此错误。错误:为microsoft.crm.sdk.data.services类型指定的属性名'fi​​rstname'无效

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

回答

5

我从错误的猜测是你的网址是错误的。

确保methodUrl参数是一样的东西:

url: <your servuer url> /XRMServices/2011/OrganizationData.svc/ContactSet" 

,因为它看起来像请求说:“我让你送什么,但在您发布它没有名字的属性上对象”

因此,检查其张贴到ContactSet

+0

感谢您的建议,它绝对张贴到正确的地方。我用小提琴来验证它发送的地点和内容。 – user1231231412 2011-12-14 21:40:27

+1

实际上,它看起来像oData使用删除空格的属性的“显示名称”。这是正确的吗?我只是打电话给ContactSet,看着字段,它显示“名字”。该属性具有名字“firstname”和显示名称“First Name”。 – user1231231412 2011-12-14 21:49:28

0

这需要架构名称作为关联实体的领域提及。

相关问题