The readers of my articles on several forums asks questions regarding something or the other and I do answer them promptly. However I feel the answers should be shared among a larger group of people. I think this blog will make this possible.
Showing posts with label PS. Show all posts
Showing posts with label PS. Show all posts
Wednesday, July 12, 2017
Thursday, November 27, 2014
Can you access ODATA with PowerShell?
Yes you can. However you need to use PowerShell Version 4.0. On the computer where this post is created PowerShell 4.0 is installed by default (Windows 8.1). But if you are using Windows 7.0 read here:
http://hodentekhelp.blogspot.com/2015/03/how-do-you-install-windows-powershell.html
Here is an example.
I take the example of using the ODATA service provided by ODATA.Org
Here is the URL of this service:
http://services.odata.org/OData/Odata.Svc
If you were to type this into you browser,you would see this.
This shows meta data of the collection in this service
Launch Windows PowerShell with elevated permissions.
Verify you are using Version 4
--------
PS C:\Windows\system32> $PSversionTable.PSversion
Major Minor Build Revision
----- ----- ----- --------
4 0 -1 -1
------------
Declare a $Categories variable as shown
$categories=Invoke-RestMethod http://Services.odata.org/OData/OData.svc/Categories
You will be returned to the next line if there are no errors
Let us see what is in categories
---------
PS C:\Windows\system32> $categories
id : http://services.odata.org/OData/OData.svc/Categories(0)
category : category
link : {link, link, link}
title : title
updated : 2014-11-27T21:11:29Z
author : author
content : content
id : http://services.odata.org/OData/OData.svc/Categories(1)
category : category
link : {link, link, link}
title : title
updated : 2014-11-27T21:11:29Z
author : author
content : content
id : http://services.odata.org/OData/OData.svc/Categories(2)
category : category
link : {link, link, link}
title : title
updated : 2014-11-27T21:11:29Z
author : author
content : content
------------------
Looks like there are three categories
Let us look at the titles and link of these categories
-------------
PS C:\Windows\system32> $categories.title
type #text
---- -----
text Food
text Beverages
text Electronics
PS C:\Windows\system32> $categories.link
rel title href
--- ----- ----
edit Category Categories(0)
http://schemas.microsoft.com/ado/200... Products Categories(0)/Products
http://schemas.microsoft.com/ado/200... Products Categories(0)/$links/Products
edit Category Categories(1)
http://schemas.microsoft.com/ado/200... Products Categories(1)/Products
http://schemas.microsoft.com/ado/200... Products Categories(1)/$links/Products
edit Category Categories(2)
http://schemas.microsoft.com/ado/200... Products Categories(2)/Products
http://schemas.microsoft.com/ado/200... Products Categories(2)/$links/Products
http://hodentekhelp.blogspot.com/2015/03/how-do-you-install-windows-powershell.html
Here is an example.
I take the example of using the ODATA service provided by ODATA.Org
Here is the URL of this service:
http://services.odata.org/OData/Odata.Svc
If you were to type this into you browser,you would see this.
This shows meta data of the collection in this service
Launch Windows PowerShell with elevated permissions.
Verify you are using Version 4
--------
PS C:\Windows\system32> $PSversionTable.PSversion
Major Minor Build Revision
----- ----- ----- --------
4 0 -1 -1
------------
Declare a $Categories variable as shown
$categories=Invoke-RestMethod http://Services.odata.org/OData/OData.svc/Categories
You will be returned to the next line if there are no errors
Let us see what is in categories
---------
PS C:\Windows\system32> $categories
id : http://services.odata.org/OData/OData.svc/Categories(0)
category : category
link : {link, link, link}
title : title
updated : 2014-11-27T21:11:29Z
author : author
content : content
id : http://services.odata.org/OData/OData.svc/Categories(1)
category : category
link : {link, link, link}
title : title
updated : 2014-11-27T21:11:29Z
author : author
content : content
id : http://services.odata.org/OData/OData.svc/Categories(2)
category : category
link : {link, link, link}
title : title
updated : 2014-11-27T21:11:29Z
author : author
content : content
------------------
Looks like there are three categories
Let us look at the titles and link of these categories
-------------
PS C:\Windows\system32> $categories.title
type #text
---- -----
text Food
text Beverages
text Electronics
PS C:\Windows\system32> $categories.link
rel title href
--- ----- ----
edit Category Categories(0)
http://schemas.microsoft.com/ado/200... Products Categories(0)/Products
http://schemas.microsoft.com/ado/200... Products Categories(0)/$links/Products
edit Category Categories(1)
http://schemas.microsoft.com/ado/200... Products Categories(1)/Products
http://schemas.microsoft.com/ado/200... Products Categories(1)/$links/Products
edit Category Categories(2)
http://schemas.microsoft.com/ado/200... Products Categories(2)/Products
http://schemas.microsoft.com/ado/200... Products Categories(2)/$links/Products
Subscribe to:
Posts (Atom)

