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; }
}
私が間違っていることについて何か考えがある人はいますか?