1

I need to get a item by a giver url. (SP2010)
I am using the Lists.asmx web services. (I can not run code on sharepoint machine).

I tried this:

SPWSList.Lists queryListService = new SPWSList.Lists();
queryListService.Credentials = System.Net.CredentialCache.DefaultCredentials;
queryListService.Url = "http://myServer/_vti_bin/Lists.asmx";

System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
System.Xml.XmlElement query = xmlDoc.CreateElement("Query");
query.InnerXml = "<Where><Contains><FieldRef Name=\"FileRef\"/><Value Type=\"Url\">"
+ "sites/mysite/file.docx</Value></Contains></Where>";

System.Xml.XmlElement viewFields = xmlDoc.CreateElement("ViewFields");
viewFields.InnerXml = "<FieldRef Name=\"ID\" />";

System.Xml.XmlElement queryOptions = xmlDoc.CreateElement("QueryOptions");
queryOptions.InnerText = "";

System.Xml.XmlNode nodeListItems = queryListService.GetListItems(string.Empty, string.Empty, query, viewFields, "10", queryOptions,null);

And I am getting the error:

System.Web.Services.Protocols.SoapException

I just have the url of the item (not the list id, view id and web id)

1

Its because you haven't passed the list name to the method GetListItems

You should use following syntax

GetListItems(listName, null, query, viewFields, null, queryOptions, null);

For more information - http://ojasmaru.blogspot.com/2012/08/sharepoint-2010-get-list-items-using.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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