I already try that one, can you please explain the step by step because its my first task with google api so i can't able to do this. please help on this.
Instead of asking people to do your work for you, perhaps you should explain exactly what you tried and what errors you got or in what way it didn't work. It might be a lot quicker for someone to fix a typo in your existing code rather than start from scratch.
I used following code for insert google contact in button click event
RequestSettings settings = new RequestSettings("computerdoctor");
ContactsRequest cr = new ContactsRequest(settings);
Contact newEntry = new Contact();
// Set the contact's name.
newEntry.Name = new Name()
{
FullName = txtfirst_name.Text,
GivenName = txtlast_time.Text,
FamilyName = txtfirst_name.Text + " " + txtlast_time.Text,
};
newEntry.Content = "Notes";
// Set the contact's e-mail addresses.
newEntry.Emails.Add(new EMail()
{
Primary = true,
Rel = ContactsRelationships.IsHome,
Address = "brajasmec@gmail.com"
});
newEntry.Emails.Add(new EMail()
{
Rel = ContactsRelationships.IsWork,
Address = "rajasekar.b@pickzy.com"
});
// Set the contact's phone numbers.
newEntry.Phonenumbers.Add(new PhoneNumber()
{
Primary = true,
Rel = ContactsRelationships.IsWork,
Value = txtcontact_no.Text,
});
// Set the contact's IM information.
newEntry.IMs.Add(new IMAddress()
{
Primary = true,
Rel = ContactsRelationships.IsHome,
Protocol = ContactsProtocols.IsGoogleTalk,
});
// Set the contact's postal address.
newEntry.PostalAddresses.Add(new StructuredPostalAddress()
{
Rel = ContactsRelationships.IsWork,
Primary = true,
Street = txt_addr1.Text,
City = txt_addr2.Text,
Region = txtlocation.Text,
Postcode = txtzipcode.Text,
Country = txt_country.Text,
FormattedAddress = txt_addr1.Text + " " + txt_addr2.Text + " " + txtlocation.Text + " " + txtzipcode.Text + " " + txt_country.Text,
});
// Insert the contact.
Uri feedUri = new Uri(ContactsQuery.CreateContactsUri("default"));
Contact createdEntry = cr.Insert(feedUri, newEntry);
but it throws error on last line "Contact createdEntry = cr.Insert(feedUri, newEntry);"
The remote server returned an error: (401) Unauthorized.
Description:
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.WebException: The remote server returned an error: (401) Unauthorized.
Source Error:
Line 226: // Insert the contact.
Line 227: Uri feedUri = new Uri(ContactsQuery.CreateContactsUri("default"));
Line 228: Contact createdEntry = cr.Insert(feedUri, newEntry);
Line 229:
Line 230:
I got your point mike but I am having all the credentials for google contact api, actually my problem was I don't know where to use that in my code can you please help on that
None
0 Points
5 Posts
Insert/edit/delete google contact through asp.net
Jul 11, 2016 05:21 AM|rajasekar.b@pickzy.com|LINK
Hi
I want insert/edit/delete my google contact through my asp.net web application, please provide the steps for integration
All-Star
194524 Points
28081 Posts
Moderator
Re: Insert/edit/delete google contact through asp.net
Jul 11, 2016 07:05 AM|Mikesdotnetting|LINK
You should start here: https://developers.google.com/google-apps/contacts/v3/
None
0 Points
5 Posts
Re: Insert/edit/delete google contact through asp.net
Jul 11, 2016 07:11 AM|rajasekar.b@pickzy.com|LINK
Hi Mike
I already try that one, can you please explain the step by step because its my first task with google api so i can't able to do this. please help on this.
All-Star
194524 Points
28081 Posts
Moderator
Re: Insert/edit/delete google contact through asp.net
Jul 11, 2016 08:11 AM|Mikesdotnetting|LINK
Instead of asking people to do your work for you, perhaps you should explain exactly what you tried and what errors you got or in what way it didn't work. It might be a lot quicker for someone to fix a typo in your existing code rather than start from scratch.
None
0 Points
5 Posts
Re: Insert/edit/delete google contact through asp.net
Jul 11, 2016 09:05 AM|rajasekar.b@pickzy.com|LINK
Thank you mike for responding us
I used following code for insert google contact in button click event
RequestSettings settings = new RequestSettings("computerdoctor");
ContactsRequest cr = new ContactsRequest(settings);
Contact newEntry = new Contact();
// Set the contact's name.
newEntry.Name = new Name()
{
FullName = txtfirst_name.Text,
GivenName = txtlast_time.Text,
FamilyName = txtfirst_name.Text + " " + txtlast_time.Text,
};
newEntry.Content = "Notes";
// Set the contact's e-mail addresses.
newEntry.Emails.Add(new EMail()
{
Primary = true,
Rel = ContactsRelationships.IsHome,
Address = "brajasmec@gmail.com"
});
newEntry.Emails.Add(new EMail()
{
Rel = ContactsRelationships.IsWork,
Address = "rajasekar.b@pickzy.com"
});
// Set the contact's phone numbers.
newEntry.Phonenumbers.Add(new PhoneNumber()
{
Primary = true,
Rel = ContactsRelationships.IsWork,
Value = txtcontact_no.Text,
});
// Set the contact's IM information.
newEntry.IMs.Add(new IMAddress()
{
Primary = true,
Rel = ContactsRelationships.IsHome,
Protocol = ContactsProtocols.IsGoogleTalk,
});
// Set the contact's postal address.
newEntry.PostalAddresses.Add(new StructuredPostalAddress()
{
Rel = ContactsRelationships.IsWork,
Primary = true,
Street = txt_addr1.Text,
City = txt_addr2.Text,
Region = txtlocation.Text,
Postcode = txtzipcode.Text,
Country = txt_country.Text,
FormattedAddress = txt_addr1.Text + " " + txt_addr2.Text + " " + txtlocation.Text + " " + txtzipcode.Text + " " + txt_country.Text,
});
// Insert the contact.
Uri feedUri = new Uri(ContactsQuery.CreateContactsUri("default"));
Contact createdEntry = cr.Insert(feedUri, newEntry);
but it throws error on last line "Contact createdEntry = cr.Insert(feedUri, newEntry);"
The remote server returned an error: (401) Unauthorized.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.WebException: The remote server returned an error: (401) Unauthorized.
Source Error:
Line 226: // Insert the contact. Line 227: Uri feedUri = new Uri(ContactsQuery.CreateContactsUri("default")); Line 228: Contact createdEntry = cr.Insert(feedUri, newEntry); Line 229: Line 230:
All-Star
194524 Points
28081 Posts
Moderator
Re: Insert/edit/delete google contact through asp.net
Jul 11, 2016 09:48 AM|Mikesdotnetting|LINK
None
0 Points
5 Posts
Re: Insert/edit/delete google contact through asp.net
Jul 11, 2016 10:08 AM|rajasekar.b@pickzy.com|LINK
I got your point mike but I am having all the credentials for google contact api, actually my problem was I don't know where to use that in my code can you please help on that
Thank you & Regards
Rajasekar