2011-12-14 94 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

這需要架構名稱作爲關聯實體的領域提及。

相關問題