Hi
Is it possible to create contacts(Person) that has no associated company, through the api? I have set the global setting "Mandatory Company on Contact" to false.
The code below causes Object Reference exception somewhere in superOffice
public async Task CreatePerson(int personId, string email, string firstName, string lastName)
{
var contactAgent = new ContactAgent(_config);
try
{
var person = await contactAgent.AddPersonAsync(0, new PersonEntity()
{
Emails = new[] { new EntityElement() { Value = email } },
Firstname = firstName,
Lastname = lastName
});
}
catch (Exception e)
{
throw;
}
}
Alle Svar (2)
Hi Snorre,
instead of creating a new PersonEntity object yourself and using contact.AddPerson, you should instead call personAgent.CreateDefaultPersonEntity, to get a valid object, and just modify it before saving it using personAgent.SavePersonEntity.