Asp.net C# - sample code for private application
can you please provide some sample code , on how to connect to xero private apps for long time authenitcation. please help to us.
As this forum is for developer API functionality requests , I’m afraid we have to decline this suggestion, but don’t take it personally – you can submit your request on Xero Developer forum https://community.xero.com/developer
-
Hanan Abdelwahab commented
This a simple example to search for a contact using email or name .If you want to get all contacts , you will use " var Contacts = private_app_api.Contacts.Find().ToList()" without the where section and loop on them.
private void GetConats()
{
X509Certificate2 cert = new X509Certificate2(@"C:\OpenSSL\bin\public_privatekey.pfx","Your Password");
XeroCoreApi private_app_api = new XeroCoreApi("https://api.xero.com/api.xro/2.0/", new PrivateAuthenticator(cert),new Consumer("Your Key", "Your Password"), null
,new DefaultMapper(), new DefaultMapper());var Contacts = private_app_api.Contacts.Find().ToList().Where(c => c.Name.StartsWith(txtContactNameOrEmail.Text.Trim()) || c.EmailAddress == txtContactNameOrEmail.Text.Trim()).FirstOrDefault();
if (Contacts != null)
///Uncomment the loop in case you want to get the whole list of contacts
//for (int i = 0; i < Contacts.; i++ )
// MessageBox.Show("The contact " + Contacts[i].FirstName + " " + Contacts[i].LastName + " is Existing with Id " + Contacts[i].Id);
MessageBox.Show("The contact " + Contacts.FirstName + " " + Contacts.LastName + " is Existing with Id " + Contacts.Id);
else
MessageBox.Show("This contat doesn't exist");
} -
Anonymous commented
can someone provide me a sample code how to get all contacts in asp.net from xero