Note that there are some explanatory texts on larger screens.

plurals
  1. POGetListitems not returning expected result
    text
    copied!<p>I have created a windows application using list.asmx (getlistitems method) to download documents from a document library which is on another server. I am able to access document names, url, etc. When I use following code to download a file, it is returning html of the login page as content of each file that I am trying to download.</p> <p>Any thoughts?</p> <pre><code> Dim spAuthentication As New Authentication() spAuthentication.Url = authenticationWSAddress spAuthentication.CookieContainer = New CookieContainer() Dim spLists As New Lists() spLists.Url = listWSAddress 'Try to login to SharePoint site with Form based authentication Dim loginResult As LoginResult = spAuthentication.Login(userName, password) Dim cookie As New Cookie() 'If login is successfull If loginResult.ErrorCode = LoginErrorCode.NoError Then 'Get the cookie collection from the authenticatin web service Dim cookies As CookieCollection = spAuthentication.CookieContainer.GetCookies(New Uri(spAuthentication.Url)) 'Get the specific cookie which contains the security token cookie = cookies(loginResult.CookieName) 'Initialize the cookie container of the list web service spLists.CookieContainer = New CookieContainer() 'set the cookie of list web service to the authenticatio cookie spLists.CookieContainer.Add(cookie) 'Dim responseNode As XmlNode = spLists.GetListCollection() 'response = responseNode.InnerXml Dim query As String = "&lt;mylistitems&gt;&lt;Query&gt;&lt;Where&gt;&lt;Eq&gt;&lt;FieldRef Name='FileDirRef' /&gt;&lt;Value Type='Url'&gt;DocLib/Property Documents/BELASERA AT FULTON (lax10027)/Master Meter Invoices&lt;/Value&gt;&lt;/Eq&gt;&lt;/Where&gt;&lt;/Query&gt;&lt;QueryOptions&gt;&lt;ViewAttributes Scope='RecursiveAll' IncludeRootFolder='False' /&gt;&lt;IncludeAttachmentUrls&gt;TRUE&lt;/IncludeAttachmentUrls&gt;&lt;ViewFields&gt;&lt;FieldRef Name='EncodedAbsUrl'/&gt;&lt;/ViewFields&gt;&lt;/QueryOptions&gt;&lt;/mylistitems&gt;" Dim doc As New XmlDocument() doc.LoadXml(query) Dim dt As DataTable = Nothing Dim queryNode As XmlNode = doc.SelectSingleNode("//Query") Dim viewNode As XmlNode = doc.SelectSingleNode("//ViewFields") Dim optionNode As XmlNode = doc.SelectSingleNode("//QueryOptions") Dim retNode As XmlNode = spLists.GetListItems("DocLib", String.Empty, queryNode, viewNode, String.Empty, optionNode, Nothing) Dim ds As New DataSet() Using sr As New StringReader(retNode.OuterXml) ds.ReadXml(sr) End Using If ds.Tables("Row") IsNot Nothing AndAlso ds.Tables("Row").Rows.Count &gt; 0 Then dt = ds.Tables("Row").Copy() For Each myrow As DataRow In dt.Rows ' myrow.Item(0) contains url of the document If myrow.Item(0) IsNot Nothing AndAlso myrow.Item(0) &lt;&gt; "" Then DownLoadAttachmentold(myrow.Item("ows_EncodedAbsUrl"), RemoveLookupID(myrow.Item("ows_FileLeafRef"))) End If Next End If Public Shared Sub DownLoadAttachment(ByVal strURL As String, ByVal strFileName As String) Dim myWebClient As New WebClient() Dim DestinationFolder As String = "C:\\DownLoads\\" Form2.RTBStatus.AppendText("Downloading File " + strFileName + " from " + strURL + " .......") ' The DownloadFile() method downloads the Web resource and saves it into the current file-system folder. myWebClient.DownloadFile(strURL, DestinationFolder + strFileName) 'Form2.RTBStatus.AppendText("Successfully Downloaded file ""{0}"" from ""{1}""", "C:\\DownLoads\\" + strFileName, strURL) Form2.RTBStatus.AppendText((ControlChars.Cr + "Downloaded file saved in the following file system folder:" + ControlChars.Cr + ControlChars.Tab + DestinationFolder)) End Sub </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload