Created
May 13, 2016 08:29
-
-
Save DominicCronin/f9c139c5a69143a53c6fb155103086c4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $params = @{ | |
| client_id='cduser' | |
| client_secret='CDUserP@ssw0rd' | |
| grant_type='client_credentials' | |
| resources='/' | |
| } | |
| $token = Invoke-RestMethod -Uri 'http://localhost:9082/token.svc' -Method POST -Body $params | |
| $Authorization = $token.token_type + ' ' + $token.access_token | |
| $query = '/Publications' | |
| $stagingUri = 'http://localhost:9081/client/v2/content.svc' + $query | |
| $stagingContent = Invoke-RestMethod -Method Get -Uri $stagingUri -Headers @{Authorization=$Authorization} | |
| if ($stagingContent) { | |
| "Staging content... there is some" | |
| $ns = @{ | |
| atom="http://www.w3.org/2005/Atom" | |
| metadata="http://docs.oasis-open.org/odata/ns/metadata" | |
| data="http://docs.oasis-open.org/odata/ns/data" | |
| m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" | |
| d="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" | |
| } | |
| # Some weirdness here. XML fragments... | |
| Select-Xml -Content $stagingContent.OuterXml -Namespace $ns -XPath "/atom:entry/atom:title" | %{$_.Node.InnerText} | |
| } else { | |
| "No data returned" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment