Powershell. Retrieve filtered information from a list using WebClient class




I need obtain information from a list using next call:

$webclient = new-object System.Net.WebClient
$webclient.UseDefaultCredentials = $true
$webpage = $webclient.DownloadString($url)

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!


3 Replies
I would recommend to use CSOM....it's not an option for you?

@Juan Carlos González Martín and @Pieter Veenstra, sorry for my delay... holiday....

The problem was concatenating strings. Using this way runs:

$url = “http://myhost/_api/web/lists/GetByTitle(%27mylist%27)/items?" + "$" + "select=Title,IDPeticio&"  + "$" + "filter=IDPeticio%20gt%205080"