SharePoint – REST Interface, JSON output

REST and JSON are hot these days, prior to SOAP and XML.

Luckily for PowerShell scripters, SharePoint has an REST interface.

And PowerShell has a JSON class.

Here is an example on how to combine both.

CLS

$creds = Get-Credential # get and save credentials

$url = "http://YourSite/_vti_bin/listdata.svc/YourList"

# Once you have the URI set,
# you can use the Invoke-RestMethod cmdlet to get the required information back:
# -UseDefaultCredentials or -Credential $cred

$ListService = Invoke-RestMethod -Uri $URL -Credential $cred

echo $ListService | select ID, Name | ConvertTo-Json

If you have more examples let’s please share.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: