Forum Discussion

María José Pedreira's avatar
María José Pedreira
Brass Contributor
Jul 05, 2017

Powershell. Retrieve filtered information from a list using WebClient class

Hello,

 

I need obtain information from a list using next call:

$url="http://myhost/_api/web/lists/GetByTitle('mylist')/items?$select=Title,CurrentYear&$filter=CurrentYear%20gt%202019"
$webclient = new-object System.Net.WebClient
$webclient.UseDefaultCredentials = $true
$webpage = $webclient.DownloadString($url)
$webpage


If I type the rest url in a browser  I obtain my results filtered. It works fine.

But the same url  in the previous code retrieves all the items. When I type $webpage, the results seem to ignore the url text after the ? symbol.

 

Thank you!

 

Resources