SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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)

    public ResponseObject addGroup()//AddGroup addGroupObj)

            string fullsite = SPContext.Current.Web.Url + "/sites/Reply Corp";

                                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!

share|improve this question
What error are you getting? – Andrey Markeev Feb 6 '12 at 8:29
"The language is not supported on the server." – Ziba Leah Feb 6 '12 at 8:37

The LCID number is wrong (the fourth parameter), it should be one of this list instead than 123:

The US-English is 1033.

Remember also that if you try to create sites with a non administrator user you should use RunWithElevatedPrivileges method.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.