Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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!

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
add comment

1 Answer

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

http://msdn.microsoft.com/es-es/goglobal/bb964664.aspx

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
add comment

Your Answer

 
discard

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.