【发布时间】:2016-12-13 15:49:30
【问题描述】:
我正在尝试使用 DotNetSDataClient library 在 Infor CRM 中添加新联系人。我试图在 Create 部分下关注this documentation。当我运行示例代码时,我收到错误“需要联系人的帐户”。这是有道理的,因为我相信数据库中的每个联系人都必须与一个帐户相关联。我修改了代码以指定现有帐户,但现在我收到错误“我们很抱歉,您遇到了错误。如果适用,请重试。”带有内部异常,“删除服务器返回错误:(500) 内部服务器错误。”
这是我的代码。
public void someFunction(){
var client = new SDataClient("https://domain/sdata/slx/dynamic/-/")
{
UserName = "username",
Password = "password"
};
var contact = new Contact
{
Account = new Account
{
AccountName = "accountName",
Id = "accountId"
},
Address = new Address
{
Address1 = "1234 Address",
City = "someCity",
PostalCode = "12345",
State = "ST"
},
FirstName = "John",
LastName = "Doe"
};
var contactOptions = new SDataPayloadOptions { Include = "Address" };
try
{
contact = client.Post(contact, null, contactOptions);
}
catch (Exception ex)
{
var error = ex.Message;
}
}
[SDataPath("accounts")]
public class Account
{
[SDataProtocolProperty(SDataProtocolProperty.Key)]
public string Id { get; set; }
public string AccountName { get; set; }
public List<Contact> Contacts { get; set; }
public string Status { get; set; }
public string Type { get; set; }
}
[SDataPath("contacts")]
public class Contact
{
[SDataProtocolProperty(SDataProtocolProperty.Key)]
public string Id { get; set; }
public Account Account { get; set; }
public Address Address { get; set; }
public string Email { get; set; }
public string FirstName { get; set; }
public string FullName { get; set; }
public string LastName { get; set; }
public DateTime? ModifyDate { get; set; }
public string Status { get; set; }
}
[SDataPath("addresses")]
public class Address
{
[SDataProtocolProperty]
public string Key { get; set; }
public string Address1 { get; set; }
public string Address3 { get; set; }
public string Address2 { get; set; }
public string City { get; set; }
public string CountryCode { get; set; }
public string Description { get; set; }
public string PostalCode { get; set; }
public string State { get; set; }
public string Street { get; set; }
}
有人知道我做错了什么吗?
【问题讨论】:
标签: c# .net saleslogix sdata