Not Able to Add contact in google Contacts using AuthSuB in Asp.net

dbcnbusrmhb

New Member
My problem is that I am not able to add contacts in google. I am using asp.net 2008.Same thing when I am using with google calender it is saving without any problem. I am not sure wheather it is a token problem or something else so i decided to ask here.Below is my code for adding Contacts\[code\] protected void Create_Click() { GAuthSubRequestFactory authFactory_con = new GAuthSubRequestFactory("cp", "ContactApp"); authFactory_con.Token = (String)Session["token"]; ContactsService ser = new ContactsService(authFactory_con.ApplicationName); ser.RequestFactory = authFactory_con; string str = ""; ContactDetail contact = new ContactDetail { Name = NameTextBox.Text + " " + LastTextBox.Text, EmailAddress1 = primaryEmailTextBox.Text, EmailAddress2 = secondryEmailTextBox.Text, Phone = phoneTextBox.Text, Mobile = MobileTextBox.Text, Street = StreetTextBox.Text, City = CityTextBox.Text, Region = RegionTextBox.Text, PostCode = PostCodeTextBox.Text, Country = CountryTextBox.Text, Details = detailsTextBox.Text }; GoogleContactService.AddContact(contact,ser); str = "<script>alert('Contact Added Sucessfully')</script>"; Response.Write(str); }\[/code\]Above function calls AddContact function of GoogleContactService. Below is the code for Add Contact Function \[code\] public void AddContact(ContactDetail contact, ContactsService GContactService) { ContactEntry newEntry = new ContactEntry(); newEntry.Title.Text = contact.Name; //newEntry.Name.FullName = contact.Name; newEntry.Name = new Name(); newEntry.Name.FullName = contact.Name; EMail primaryEmail = new EMail(contact.EmailAddress1); primaryEmail.Primary = true; primaryEmail.Rel = ContactsRelationships.IsWork; newEntry.Emails.Add(primaryEmail); EMail secondaryEmail = new EMail(contact.EmailAddress2); secondaryEmail.Rel = ContactsRelationships.IsHome; newEntry.Emails.Add(secondaryEmail); PhoneNumber phoneNumber = new PhoneNumber(contact.Phone); phoneNumber.Rel = ContactsRelationships.IsHome ; newEntry.Phonenumbers.Add(phoneNumber); PhoneNumber phoneNumber_ = new PhoneNumber(contact.Mobile ); phoneNumber_.Primary = true; phoneNumber_.Rel = ContactsRelationships.IsMobile ; newEntry.Phonenumbers.Add(phoneNumber_); newEntry.PostalAddresses.Add(new StructuredPostalAddress() { Rel = ContactsRelationships.IsWork, Primary = true, Street = contact.Street , City = contact.City , Region = contact.Region , Postcode = contact.PostCode , Country = contact.Country , FormattedAddress = contact.Street + " , " + contact.City + " , " + contact.Region + " , " + contact.PostCode + " , " + contact.Country, }); newEntry.Content.Content = contact.Details; Uri feedUri = new Uri(ContactsQuery.CreateContactsUri("default")); // Uri feedUri = new Uri("http://www.google.com/m8/feeds/contacts/default/full"); System.Net.ServicePointManager.Expect100Continue = false; ContactEntry createdEntry = (ContactEntry)GContactService.Insert(feedUri, newEntry);}\[/code\]I am getting token at page loadBelow is the error getting when I am trying to add Contact.GDataRequestException was unhandled by user codeExecution of request failed: https//www.google.com/m8/feeds/contacts/default/full
 
Back
Top