Invoke-SPORestMethod

Sends an HTTP or HTTPS request to a SharePoint Online REST-compliant web service.

Invoke-SPORestMethod -Url <UrlPipeBind> [-Method [<WebRequestMethod>]] [-Body [<Object>]] [-RequestDigest [<String>]] [-ETag [<String>]] [-XHTTPMethod [<WebRequestMethod>]] [-JSONVerbosity [<String>]] [-OutFile [<String>]]

Parameters

1

ParameterRequiredTypeDescription
UrlTrueUrlPipeBind

The REST endpoint URL to call.

MethodFalseWebRequestMethod

Specifies the method used for the web request. The default value is "Get".

BodyFalseObject

Specifies the body of the request. The body is the content of the request that follows the headers. You can also pipe a body value to Invoke-SPORestMethod.

RequestDigestFalseString

The "X-RequestDigest" header to set. This is most commonly used to provide the form digest variable. Use "(Invoke-SPORestMethod -Url "https://contoso.sharepoint.com/_api/contextinfo" -Method "Post").GetContextWebInformation.FormDigestValue" to get the Form Digest value.

ETagFalseString

The "If-Match" header to set. Provide this to make sure you are not overwritting an item that has changed since you retrieved it.

XHTTPMethodFalseWebRequestMethod

To work around the fact that many firewalls and other network intermediaries block HTTP verbs other than GET and POST, specify PUT, DELETE, or MERGE requests for -XHTTPMethod with a POST value for -Method.

JSONVerbosityFalseString

The OData verbosity of the data to return. Valid values are "Verbose", "MinimalMetadata", and "NoMetadata".

OutFileFalseString

If the returned data is a binary data object such as a file from a SharePoint site specify the output file name to save the data to.

Detailed Description

This function sends an HTTP or HTTPS request to a Representational State Transfer (REST)-compliant ("RESTful") SharePoint Online web service. The Connect-SPOSite cmdlet must be run first in order to set the credentials for the environment.

Some source code for this cmdlet was referenced from http://blog.vgrem.com/2014/02/27/working-with-the-sharepoint-online-rest-service-via-powershell/.

Copyright 2016 Falchion Consulting, LLC

> For more information on this cmdlet and others:

> http://blog.falchionconsulting.com/

> Use of this cmdlet is at your own risk.

> Gary Lapointe assumes no liability.

Examples

------------------EXAMPLE------------------

PS C:\> Connect-SPOSite -Url "https://contoso.sharepoint.com/" -Credential "admin@contoso.com"
PS C:\> Invoke-SPORestMethod "https://contoso.sharepoint.com/_api/web"

This example invokes the REST call at https://contoso.sharepoint.com/_api/web.