3

In a remote client, I'm trying to create a new list in a sharepoint site. Right now, I'm building a CAML string and sending it via http post to my sharepoint site. I've used this method to update list items and create dws folders, but I can't seem to get AddList to work. I get an error "Remove server returned error:NotFound."

Any ideas? I'm pretty certain it's not an authentication issue since I've used the exact same method in this same program to do the previously mentioned functions. The sharepoint site I'm adding the list to is a test site in which I have full read/write capabilities.

here is my CAML:

    string soapEnv =
    "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
    "<soap:Envelope " + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance"+
    "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"" +
    " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"+
    "<soap:Body>" +
    "<AddList xmlns=\"http://schemas.microsoft.com/sharepoint/soap\">"+
        "<listName>" + listName + "</listName>" +
        "<description>" + "A Test list" + "</description>" +
        "<templateID>100</templateID>" +
    "</AddList>" +
    "</soap:Body>" +
    "</soap:Envelope>";
    return soapEnv;

I send this in an http Post with these settings:

    uri = "[my sharepoint site]/_vti_bin/lists.asmx";
    WebClient client = new WebClient();
    client.Headers["SOAPAction"] = "http://schemas.microsoft.com/sharepoint/soap/";
    client.Headers["content-type"] = "text/xml; charset=utf-8";
    client.Encoding = Encoding.UTF8;
    client.UploadStringCompleted += UploadStringCompleted;
    try
    {
        client.UploadStringAsync(new Uri(uri, UriKind.Absolute), "POST", CAML);
    }
    catch (Exception ex)
    {
        MessageBox.Show("Error in upload string async: " + ex.Message);
    }
3
  • Forgot to add this is a Silverlight app!!
    – Anonymous
    Commented Mar 4, 2010 at 18:48
  • @pclem: Feel free to edit your question with any extra info you'd like to provide. Welcome to SharePoint Overflow! :-)
    – Alex Angas
    Commented Mar 4, 2010 at 22:41
  • Are you using Visual Studio? Commented Mar 9, 2010 at 13:32

1 Answer 1

0

I was missing a quotation mark in the soap header...go figure. The end of the first line is missing \" before the quotation mark to close the open quote on xmlns:xsi

<soap:Envelope " + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance"+
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"" +
" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"+
1
  • That's why I never use strings to build Xml documents. I prefer using XDocument/XElement/XAttribute Commented Mar 11, 2010 at 15:52

Your Answer

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