Home Retrieve document ID from SharePoint 2010 via SOAP Web Services - GetListItems
Post
Cancel

Retrieve document ID from SharePoint 2010 via SOAP Web Services - GetListItems

Get a specific item from a SharePoint 2010 library using GetListItems.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Build the CAML Query
System.Text.StringBuilder oSb = new System.Text.StringBuilder();
oSb.Append("     <Query>");
oSb.Append("         <Where>");
oSb.Append("             <Eq>");
oSb.Append("                  <FieldRef Name=\"FileLeafRef\" />");
oSb.Append("                  <Value Type=\"Text\">" + fileName +"</Value>");
oSb.Append("             </Eq>");
oSb.Append("        </Where>");
oSb.Append("    </Query>");
 
string sResult = oSb.ToString();
XmlDocument CAMLqueryXML = new XmlDocument();
CAMLqueryXML.LoadXml(sResult);
 
//Build the CAML Query Options
oSb.Clear(); // Clear the string builder
oSb.Append("    <QueryOptions>");
oSb.Append("         <Folder>" + libraryName + "/</Folder> />");
oSb.Append("    </QueryOptions>");
string CAMLqueryOptions = oSb.ToString();
 
XmlDocument CAMLqueryOptionsXML = new XmlDocument();
CAMLqueryOptionsXML.LoadXml(CAMLqueryOptions);
 
// Execute GetListItems
XmlNode queryResults = lists.GetListItems(libraryName, null, CAMLqueryXML, null, null, CAMLqueryOptionsXML, null);
This post is licensed under CC BY 4.0 by the author.