detale
detale

Reputation: 12930

Set Excel / Word Online document readonly using Graph API

When an Excel or Word file on SharePoint is opened,it is in edit mode by default.
From Excel/Word online menu, there is a menu option to set the file read-only, called "Protect Workbook" in Excel inline and "Protect Document" in Word online, as shown in the screenshot.

enter image description here

Next time the file is open in Excel/Word online, it is opened in read-only mode and shows an "Edit Anyway" button to switch to edit mode, which is exactly what I need.

enter image description here

Question is: How can I use Graph API to programatically set an Excel or Word document as read-only?

Upvotes: 0

Views: 759

Answers (1)

Akhil Surapuram
Akhil Surapuram

Reputation: 682

HTTP request

POST /workbook/worksheets/{id|name}/protection/protect

Request headers Name Description Authorization Bearer {token}. Required.
Workbook-Session-Id Workbook session Id that determines if changes are persisted or not. Optional. Request body In the request body, provide a JSON object with the following parameters.

Parameter Type Description options WorkbookWorksheetProtectionOptions Optional. sheet protection options. Response

If successful, this method returns 200 OK response code. It does not return anything in the response body.

Kindly look at https://learn.microsoft.com/en-us/graph/api/worksheetprotection-protect?view=graph-rest-1.0&tabs=http for more Information

Upvotes: 0

Related Questions