I am creating a Silverlight 4 web resource in CRM 2011 using the Otganizational Data service. I am able to create Campaigns, Marketing Lists, and Print Activities as well as linking the lists to the campaigns. However when I go to link the marketing lists to the print activity using the CampaignActivityItem I get a 403 Forbidden error. Below is the code I am using.
Models.CampaignActivityItem activityItem = new CampaignActivityItem()
{
CampaignActivityItemId = Guid.NewGuid(),
ItemId = EmailMarketingList.ListId, //Id of my marketing list I have
//already created
CampaignActivityId = new Models.EntityReference()
{
Id = MyCampaignPrintActivity.ActivityId, //Id of the print activity
//I have already created
LogicalName = "CampaignActivity",
Name = "CampaignActivity"
}
};
context.AddObject("CampaignActivityItemSet", activityItem);
context.BeginSaveChanges(System.Data.Services.Client.SaveChangesOptions.ContinueOnError, OnChangesSaved, context);
private void OnChangesSaved(IAsyncResult result)
{
// Use the Dispatcher to ensure that the
// asynchronous call returns in the correct thread.
OnUiThread(() =>
{
try
{
DataServiceResponse response = context.EndSaveChanges(result);
}
catch (DataServiceRequestException ex) // Errors with code=403
// message=Forbidden
{
WriteOperationResponse(ex.Response, "ListLink");
}
catch (InvalidOperationException ex)
{
MessageBox.Show(ex.Message);
}
finally
{
}
}
);
}
Any direction on what I am doing wrong would be greatly appreciated. Using the context I am able to perform actions on other objects but not the CampaignActivityItemSet.