Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Listdata.svc not filtering

$
0
0

I'm running SharePoint 2010 and I have a requirement to be able to query SharePoint from Powershell without having the SharePoint snap-in. I have been experimenting with some code that I found but I'm having trouble filtering the list items. The script below always displays all the items in the output when I'm expecting one item. What's the best way to filter list items?

$url = "https://mysite/market/_vti_bin/listdata.svc/Products?$filter=Title eq 'Movies'"

$request = [System.Net.WebRequest]::Create($url) 
$request.UseDefaultCredentials = $true 
$request.Accept = ‘application/json;odata=verbose’

$response = $request.GetResponse() 
$reader = New-Object System.IO.StreamReader $response.GetResponseStream() 
# ConvertFrom-Json : Cannot convert the Json string because a dictionary converted from it contains duplicated keys ‘Id’ and ‘ID’. 
$response = $reader.ReadToEnd() 
#$response = $reader.ReadToEnd() -creplace ‘"ID":’, ‘"DummyId":’

$result = ConvertFrom-Json -InputObject $response 
$result.d.results | select Id, Title


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>