Lists.asmx, GetList and “Value cannot be null”

I discovered today that the GetList() method in lists.asmx web service has to be called very carefully or it’s prone to throw a mysterious “Value cannot be null” exception (and that’s assuming you can get past the even worse generic error message, “Exception of type ‘Microsoft.SharePoint.SoapServer.SoapServerException’ was thrown.”)  Specifically, I found that you can’t provide any kind of prefix on the GetList method.  The following jQuery snippet illustrates the point:

image

If you do that, the web service responds with “Value cannot be null” as per this fiddler-provided HTTP transcript:

<?xml version="1.0" encoding="utf-8"?>
  <soap:Envelope
     xmlns:soap="
http://schemas.xmlsoap.org/soap/envelope/"    
     xmlns:xsi=”
http://www.w3.org/2001/XMLSchema-instance
     xmlns:xsd="
http://www.w3.org/2001/XMLSchema">

  <soap:Body>
    <soap:Fault>
      <faultcode>soap:Server</faultcode>
      <faultstring>
        Exception of type ‘Microsoft.SharePoint.SoapServer.SoapServerException’ was thrown.
      </faultstring>
      <detail>
        <errorstring xmlns="
http://schemas.microsoft.com/sharepoint/soap/">
Value cannot be null.
        </errorstring>
      </detail>
    </soap:Fault>
  </soap:Body>
</soap:Envelope>

Of course, you probably wouldn’t add that “s0” prefix on your own, but some tools are prone to do it (like Eclipse).

This is all the more confusing / frustrating because other methods tolerate prefixes.  For instance, the GetListCollection method doesn’t mind if it’s been prefixed, even with nonsense prefixes like “xyzzy”:

image

This “value cannot be null” seems fairly common with lists.asmx so hopefully this will help someone out in future.

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

One thought on “Lists.asmx, GetList and “Value cannot be null”

Leave a Reply

Your email address will not be published. Required fields are marked *