I have a site collection inside my SharePoint online tenant with the following url /sites/dev3/
. I have the following code inside my Remote Event Receiver, where the RER get fired when items are added inside a custom list. Now i am creating a new sub-site under the site collection where i sub-site title will be equal to the list item title:-
private void HandleItemAdded(SPRemoteEventProperties properties) { using (ClientContext clientContext = TokenHelper.CreateRemoteEventReceiverClientContext(properties)) { if (clientContext != null) { try { List photos = clientContext.Web.Lists.GetById( properties.ItemEventProperties.ListId); ListItem item = photos.GetItemById( properties.ItemEventProperties.ListItemId); clientContext.Load(item); clientContext.ExecuteQuery(); item["Title"] += "updated "; item.Update(); WebCreationInformation creation = new WebCreationInformation(); creation.Url = item["Title"].ToString(); creation.Title = item["Title"].ToString(); Web newWeb = clientContext.Web.Webs.Add(creation); // Retrieve the new web information. clientContext.Load(newWeb, w => w.Title); clientContext.ExecuteQuery(); clientContext.ExecuteQuery(); } catch (Exception oops) { System.Diagnostics.Trace.WriteLine(oops.Message); }
but the above code will raise the following exeption:-
“The URL ‘/sites/dev3/testupdated ‘ is invalid. It may contain illegal characters, or be too long.”
so can anyone advice on this please?