Prep for RESO plugfest


From

image

image

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

}

Advertisements

About home_pw@msn.com

Computer Programmer who often does network administration with focus on security servers. Very strong in Microsoft Azure cloud!
This entry was posted in coding theory. Bookmark the permalink.