0

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!

2
  • What error are you getting? Commented Feb 6, 2012 at 8:29
  • "The language is not supported on the server."
    – Ziba Leah
    Commented Feb 6, 2012 at 8:37

1 Answer 1

3

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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