Prep for RESO plugfest




To use this, we will need to (a) not use default credentials, (b) change the URl, and (c) amend the xml parsing to match the entities being returned by a RESO webapi server.


#Construct the WebClient object

$wc = New-Object System.Net.WebClient

$wc.UseDefaultCredentials = $true

#Query OData service with url

$queryUri = http://localhost:42203/NorthwindOData.svc/Categories(1)/Products?$top=5

[xml] $responseXML = $wc.DownloadString($queryUri)

#Parse query result in XML format

$entities = $responseXML.SelectNodes(“//*[local-name() = ‘properties’ ]”)

ForEach($entity in $entities) {

$prodID = $entity.SelectSingleNode(“./*[local-name() = ‘ProductID’]”).InnerText;

$prodName = $entity.SelectSingleNode(“./*[local-name() = ‘ProductName’]”).InnerText;

$prodUnitPrice = $entity.SelectSingleNode(“./*[local-name() = ‘UnitPrice’]”).InnerText;

$prodLine = [string]::Format(“ID:{0}, Name:{1}, UnitPrice:{2}”, $prodID, $prodName,$prodUnitPrice)

Write-Host $prodLine -foregroundcolor Green



About home_pw

Computer Programmer who often does network administration with focus on security servers. Sometimes plays at slot machine programming.
This entry was posted in coding theory. Bookmark the permalink.