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

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);
    }
share|improve this question
    
Forgot to add this is a Silverlight app!! –  Anonymous Mar 4 '10 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 Mar 4 '10 at 22:41
    
Are you using Visual Studio? –  Charles Lee Mar 9 '10 at 13:32
add comment

1 Answer 1

up vote 0 down vote accepted

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/\">"+
share|improve this answer
    
That's why I never use strings to build Xml documents. I prefer using XDocument/XElement/XAttribute –  Wictor Wilen MCA MCM MVP Mar 11 '10 at 15:52
add comment

Your Answer

 
discard

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