【问题标题】:Error: the property name 'firstname' specified for the type microsoft.crm.sdk.data.services is not valid错误:为类型 microsoft.crm.sdk.data.services 指定的属性名称“名字”无效
【发布时间】:2012-01-20 13:51:29
【问题描述】:

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

【问题讨论】:

    标签: c# wcf jquery dynamics-crm dynamics-crm-2011


    【解决方案1】:

    它采用关联实体字段中提到的架构名称。

    【讨论】:

      【解决方案2】:

      我从错误中猜测是您的网址错误。

      确保methodUrl 参数类似于:

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

      看起来请求是在说“我收到了您发送的内容,但是您将其发布到的地方没有对象上的名字属性”

      所以请检查其发帖到ContactSet

      【讨论】:

      • 感谢您的建议,它肯定会发布到正确的位置。我已经使用 fiddler 来验证它发送的位置和内容。
      • 实际上,oData 似乎使用删除了空格的属性的“显示名称”。这是正确的吗?我刚刚调用了 ContactSet 并查看了这些字段,它显示了“FirstName”。该属性的名称为“firstname”,显示名称为“First Name”。
      • 是的,没错,它不是小写的架构名称,如果您浏览它,您可以找到要使用的案例
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-01
      • 2018-03-31
      • 1970-01-01
      • 2020-02-26
      • 2018-01-18
      • 1970-01-01
      相关资源
      最近更新 更多