I'm creating a web service to "connect" a my app to Sharepoint.. I want to expose a method to programmatically create a web site: imagine to have in input things like "name", "description", "url" and so on...
I tried this way: (Obv this is a "static" version in which parameters are constants, next step is to pass him the values in the AddGroup Obj)
[WebMethod]
public ResponseObject addGroup()//AddGroup addGroupObj)
{
try
{
string fullsite = SPContext.Current.Web.Url + "/sites/Reply Corp";
Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(fullsite))
{
site.AllowUnsafeUpdates = true;
site.AllWebs.Add("RELATIVE", "TITOLO", "DESCRIZIONE", 1033, "Sfera", false, false); //1033 = English
//How to mess up with groups?
}
});
return new ResponseObject() { SPResultStatus = ResponseObjectSPResultStatus.SUCCESS };
}
catch (Exception exx)
{
return new ResponseObject() { Message = exx.Message, ExceptionType = exx.GetType().ToString(), Stacktrace =exx.StackTrace, SPResultStatus = ResponseObjectSPResultStatus.FAILURE, };
}
}
What i'm doing wrong?
The "Sfera" is a Custom Template which exists on the site..
The exception I'm getting now is:
File or arguments not valid for site template 'Sfera'.
There is another way to assign a custom template?? Thank you very much!