Skip to 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 AAD 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 full.
--query [query]
JMESPath query string. See for more information and examples
-o, --output [output]
Output type. json,text,csv,md. 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".


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.

m365 request --method post --url "" --body '{ "Title": "New title" }' --content-type "application/json" --x-http-method "PATCH"

Call the Microsoft Graph to get a profile photo.

m365 request --url "\$value" --filePath ./profile-pic.jpg