Skip to main content


Executes the specified web request using CLI for Microsoft 365


m365 request [options]


-u, --url <url>

The request URL.

-m, --method [method]

The HTTP request method. Accepted values are get, post, put, patch, delete, head, options. The default value is get.

-r, --resource [resource]

The resource uri for which the CLI should acquire a token from Microsoft Entra ID in order to access the service.

-b, --body [body]

The request body. Optionally use @example.json to load the body from a file.

-p, --filePath [filePath]

The file path to save the response to. This option can be used when downloading files.

-h, --help [help]

Output usage information. Optionally, specify which section of command's help you want to see. Allowed values are options, examples, remarks, response, full. Default is options.

--query [query]

JMESPath query string. See for more information and examples.

-o, --output [output]

Output type. json, text, csv, md, none. Default json.


Runs command with verbose logging.


Runs command with debug logging.


When executing a request, CLI will take care of the very basic configuration, and you'll need to specify all additional information, such as headers, method and body. CLI will take care for you of:

  • applying compression and handling throttling,
  • setting the accept to application/json if you don't specify it yourself,
  • setting the authorization header to the bearer token obtained for the resource determined from the request URL

If you specify the resource option, the CLI will try to retrieve a valid token for the resource instead of determining the resource based on the url. The value doesn't have to be a URL. It can be also a URI like app://<guid>.

Specify additional headers by typing them as options, for example: --content-type "application/json", --if-match "*", --x-requestdigest "somedigest".

You can simplify the request by using tokens for the url option. Following tokens are available:

  • @graph resolves to
  • @graphbeta resolves to
  • @spo resolves to the current SharePoint URL if available. You can set a SharePoint URL using the spo set command.

When building the request, depending on the shell you use, you might need to escape all $ characters in the URL, request headers, and the body. If you don't do it, the shell will treat it as a variable and will remove the following word from the request, breaking the request.


Call the SharePoint Rest API using a GET request with a constructed URL containing expands, filters and selects.

m365 request --url "\$filter=IsShareByEmailGuestUser eq true&\$expand=Groups&\$select=Title,LoginName,Email,Groups/LoginName" --accept "application/json;odata=nometadata"

Call the Microsoft Graph beta endpoint using a GET request.

m365 request --url ""

Call the SharePoint API to retrieve a form digest.

m365 request --method post --url ""

Call the SharePoint API to update a site title using the @spo token.

m365 request --method post --url "@spo/sites/project-x/_api/web" --body '{ "Title": "New title" }' --content-type "application/json" --x-http-method "PATCH"

Call the Microsoft Graph to get a profile photo using the @graphbeta token.

m365 request --url '@graphbeta/me/photo/$value' --filePath ./profile-pic.jpg


The responses below are an example based on the url option with the value ''. The output may differ based on the url options

"@odata.context": "$metadata#users/$entity",
"businessPhones": [
"displayName": "John Doe",
"givenName": "John",
"jobTitle": null,
"mail": "",
"mobilePhone": null,
"officeLocation": null,
"preferredLanguage": "en-US",
"surname": "Doe",
"userPrincipalName": "",
"id": "1df1fffa-62b8-44a9-9c7c-49853f5b4ac6"