我正在尝试使用DotNetSDataClient 库在 Infor CRM 中添加新联系人。我已尝试在“创建”部分下遵循此文档。当我运行示例代码时,我收到错误“需要联系人的帐户”。这是有道理的,因为我相信数据库中的每个联系人都必须与一个帐户相关联。我修改了代码以指定现有帐户,但现在我收到错误“我们很抱歉,您遇到了错误。如果适用,请重试。” 带有内部异常,“删除服务器返回错误:(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; }
}
有人对我做错了什么有任何想法吗?