I am trying to create a sharepoint app to provision site collections, I downloaded the latest sharepoint client sdk, and practically my code is the same as the one from SPC3999 Rob Howard on Channel 9.
http://channel9.msdn.com/Events/SharePoint-Conference/2014/SPC3999 (check the first 20 minutes)
So, something really weird is happening with my VS 2013. I put a breakpoint on the first line of the button click, but debugger is not stopping there, however the code is being called with the error on the post title.
protected void btnCreate_Click(object sender, EventArgs e)
{
Uri tenantadminUrl = new Uri("https://xxx-admin.sharepoint.com");
string accessToken = TokenHelper.GetAppOnlyAccessToken(
TokenHelper.SharePointPrincipal,
tenantadminUrl.Authority,
TokenHelper.GetRealmFromTargetUrl(tenantadminUrl)).AccessToken;
var newSite = new SiteCreationProperties()
{
Url="https://xxx.sharepoint.com/sites/" + txtName.Text,
Owner= txtOwner.Text,
Template="STS#0",
Title = "App provisioned site" + txtName.Text,
StorageMaximumLevel = 1000,
StorageWarningLevel = 500,
TimeZoneId = 7,
UserCodeMaximumLevel =7,
UserCodeWarningLevel=1
};
using(var clientContext=TokenHelper.GetClientContextWithAccessToken(tenantadminUrl.ToString(), accessToken))
{
var tenant = new Tenant(clientContext);
var spoOperation = tenant.CreateSite(newSite);
clientContext.Load(spoOperation);
clientContext.ExecuteQuery();
}
}