static void Main(string[] args) { // applicationName is your Infusionsoft application name (i.e. https://<username>.infusionsoft.com) // If nothing else, it can be found when you log in to Infusionsoft under the "Your Accounts" page const string applicationName = "[APPNAME]"; // Your private key can be found under "Accounts & settings -> My info -> API token" const string privateKey = "[PRIVATEKEY]"; var api = new ApiRequest(applicationName, privateKey); var contact = new Contact { FirstName = "John", LastName = "Doe", Email = "*****@*****.**" }; int id = api.ContactService.AddContact(contact, new [] { 103, 93 }); }
public int AddContact(Contact contact, IEnumerable<int> tags = null) { var proxy = XmlRpcProxyGen.Create<IContactService>(); proxy.Url = BaseUrl; var data = new XmlRpcStruct(); foreach (var propertyInfo in contact.GetType().GetProperties().Where(propertyInfo => propertyInfo.CanRead)) { var value = propertyInfo.GetValue(contact, null); if (value != null) data.Add(propertyInfo.Name, value); } int contactId = proxy.Add(PrivateKey, data); if (tags != null) foreach (var tagId in tags) proxy.AddTag(PrivateKey, contactId, tagId); return contactId; }