Hi all,
I'm writing some code to create various entries in Google apps for a number
of users. I am running code under a super administrator account.
I can successfully create appointments for other users using the following:
==============
var domain = "mydomain.com";
var adminUsername = "admin";
var adminPassword = "admin";
var targetUser = "bob.builder@" + domain;
var service = new CalendarService("Appointment Creator");
service.setUserCredentials(adminUsername + "@" + domain, adminPassword);
var postUri = new Uri("http://www.google.com/calendar/feeds/" + targetUser
+ "/private/full");
var entry = new CalendarEntry
{
Title = new AtomTextConstruct { Text = "New Appointment" },
Location = new Where("ABC1", "ABC2", "ABC3"),
};
service.Insert(postUri, entry);
==============
Note that I've replaced my domain and log on details with dummy values!
I have similar code to create contacts:
==============
var domain = "mydomain.com";
var adminUsername = "admin";
var adminPassword = "admin";
var targetUser = "bob.builder@" + domain;
var service = new ContactsService("Create Contact");
service.setUserCredentials(adminUsername + "@" + domain, adminPassword);
var postUri = new Uri("https://www.google.com/m8/feeds/contacts/" +
targetUser + "/full/");
var newEntry = new ContactEntry();
newEntry.Title.Text = "John Doe";
EMail primaryEmail = new EMail("[email protected]");
primaryEmail.Primary = true;
primaryEmail.Rel = ContactsRelationships.IsWork;
newEntry.Emails.Add(primaryEmail);
EMail secondaryEmail = new EMail("[email protected]");
secondaryEmail.Rel = ContactsRelationships.IsHome;
newEntry.Emails.Add(secondaryEmail);
PhoneNumber phoneNumber = new PhoneNumber("555-555-5555");
phoneNumber.Primary = true;
phoneNumber.Rel = ContactsRelationships.IsMobile;
newEntry.Phonenumbers.Add(phoneNumber);
var postalAddress = new StructuredPostalAddress();
postalAddress.City = "Boston";
postalAddress.Primary = true;
postalAddress.Rel = ContactsRelationships.IsHome;
newEntry.PostalAddresses.Add(postalAddress);
newEntry.Content.Content = "Who is this guy?";
service.Insert(postUri, newEntry);
==============
This code doesn't work! Here is the error I'm getting:
Exception: Execution of request failed:
https://www.google.com/m8/feeds/contacts/[email protected]/full
Inner Exception: The remote server returned an error: (403) Forbidden.
I don't understand why the appointments code works but the contacts code
doesn't. Worst still, if I replace the target user with default, the
contact code is able to save a user to the admin account with no issue.
Has anyone seen anything like this before, and does anyone have any
solutions? Any suggestions gratefully received.
Thanks in advance,
Steve.
--
You received this message because you are subscribed to the Google
Groups "Google Contacts, Shared Contacts and User Profiles APIs" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://code.google.com/apis/contacts/community/forum.html