Monday, May 28, 2018

Set O365 group classification via Graph API

Some time ago MS announced possibility to specify groups classifications – see e.g. Classifications for Office365 Groups and Microsoft Teams. After you configured classifications on tenant level like shown in mentioned article when you go to Sharepoint app from your Office 365 App launcher (it will lead to https://{tenant} and choose “+ Create site” from the header – you will see dropdown list with specified classifications:


When you will create new site classification will be shown in the header:


Also if you will get related group via Graph API – classification will be returned with other group’s properties:


will return

  "@odata.context": "$metadata#groups('{id}')/classification",
  "value": "internal"

But is it possible to update group’s classification programmatically? If we just try to send PACTH request on{id} endpoint we will get the following error:

    "error": {
        "code": "Request_BadRequest",
        "message": "Property 'classification' is read-only and cannot be set.",
        "innerError": {
            "request-id": "...",
            "date": "2018-05-28T14:22:55"

The answer is however yes it is possible: in order to set classification of O365 group via Graph API you need to use beta endpoint instead of v1.0:{id}. In this case property should be successfully updated.

Note that team site classification is stored in own property Site.Classification. So if you updated group’s classification you may also want to update classification of related site. If you use SiteExtension.SetSiteClassification from OfficeDevPnP both actions will be done automatically.

No comments:

Post a Comment