What’s new and what’s changed in SharePoint Online REST API in August-October 2019

I continue exploring REST API changes using my tool called SharePoint REST API Metadata Explorer. Here I post only some interesting findings, the full log is available for you on the SharePoint REST API Metadata Explorer web site under the "API Changelog" tab. 

Disclaimer

Please note, that all changes are gathered from Targeted tenant. Most likely these changes haven’t been officially introduced yet, use this post as spoilers to potential upcoming features. If you want to use APIs mentioned here in production, please check corresponding official documentation to make sure they are available.

AI, Machine Learning and Knowledge hub

The previous week was "Ignite" week. A lot of new things were introduced. Including innovations in the AI area.

Project Cortex uses AI to reason over content across teams and systems, recognizing content types, extracting important information, and automatically organizing content into shared topics like projects, products, processes and customers.

Learn more about Project Cortex here and at the Ignite breakout session.

SharePoint REST API also was adjusted and now includes a lot of new components around AI. For example, there is a new root endpoint _api/machinelearning or _api/KnowledgeHub, _api/models, _api/publication. New types like SPMachineLearningHub and some others. That's all the result of innovations introduced at the Ignite. They don't work properly yet ("Flight ContentCenterEnabled is not enabled for this tenant" and other errors), we don't have documentation, but I'm expecting that we will see some info about this endpoints and about Project Cortex in general in the nearest future. 

SharePoint fields - enable or disable indexing

Two new methods were added to manage the indexed fields. 

How to enable\disable field indexing:

### Enable index
POST {{siteUrl}}/_api/web/lists/getbytitle('Clients')/fields/GetByTitle('Company')/EnableIndex()
Accept: application/json;odata=verbose
Content-Type: application/json
X-RequestDigest: {{digest}}

### DisableIndex
POST {{siteUrl}}/_api/web/lists/getbytitle('Clients')/fields/GetByTitle('Company')/DisableIndex()
Accept: application/json;odata=verbose
Content-Type: application/json
X-RequestDigest: {{digest}}

A new enum represents an indexed state:

public enum FieldIndexStatus
    {
        None = 0,
        Indexed = 1,
        Enabling = 2,
        Disabling = 3
    }

Audience targeting for navigation is very close to release

It was introduced at the Ignite 2018 (a year ago, but again was demoed at Ignite 2019)! Hopefully we are now very close to release. According to the SharePoint roadmap, it will be released in December 2019.

SP.MenuState received a new property AudienceIdsSP.Web received a new property NavAudienceTargetingEnabled

SP.Web changes

A new method GetAllClientSideComponents was added: 

### Get client side components
GET {{siteUrl}}/_api/web/GetAllClientSideComponents()
Accept: application/json;odata=verbose

It returns all client-side components such as spfx web parts, extensions, library components available on the web level. 

I looked through all the components and found a few interesting ones. For example Fluid embed:

{
		"manifestVersion": 2,
		"id": "aa986256-02ae-4e20-b2ab-76de490e3d5d",
		"alias": "FluidEmbedWebPart",
		"componentType": "WebPart",
		"version": "1.0.0",
		"safeWithCustomScriptDisabled": true,
		"hiddenFromToolbox": true,
		"preconfiguredEntries": [{
				"groupId": "5c03119e-3074-46fd-976b-c60198311f70",
				"group": {
					"default": "Other"
				},
				"title": {
					"default": "***Fluid Embed",
					"en-US": "***Fluid Embed"
				},
				"description": {
					"default": "***Embed Fluid components into SharePoint Pages.",
					"en-US": "***Embed Fluid components into SharePoint Pages."
				},
				"officeFabricIconFontName": "SharepointLogo",
				"properties": {
					"componentUrl": ""
				}
			}

Fluid Framework was introduced at Ignite 2019, check out the blog post or watch break out session. It seems that there is a webpart to embed Fluid components into a SharePoint page, which sounds reasonable. 

I also found a few other quite surprising things, for example:

"preconfiguredEntries": [{
				"groupId": "5c03119e-3074-46fd-976b-c60198311f70",
				"group": {
					"default": "Other"
				},
				"title": {
					"default": "***Poll Webpart",
					"en-US": "***Poll Webpart"
				},
				"description": {
					"default": "***Webpart to demo tiered caching on Dev Kitchen",
					"en-US": "***Webpart to demo tiered caching on Dev Kitchen"
				},
				"officeFabricIconFontName": "SharepointLogo",
				"properties": {
					"label": "This is an example property"
				}
			}
		],

"Webpart to demo tiered caching on Dev Kitchen"?? What the web part from Dev Kitchen is doing in my tenant? :)

A new property regarding modernization was added: IsHomepageModernized. And IsProvisioningComplete which is interesting because I don't know exactly what it means. Maybe it indicates site script provisioning is completed. 

Page publishing

SP.Publishing.SitePage received a new method called SchedulePublish. It also was mentioned at Ignite - read the post or watch a session. You will be able to schedule the publishing of a page at any desired time. Better SMM for your intranets :). 

Hub sites

Some changes were introduced in the hub sites area. Hub site object now has EnablePermissionsSync property. SP.Site object received CanSyncHubSitePermissions and HubSiteSynchronizableVisitorGroup properties. 

It looks like in the future we will be able to synchronize permissions of a hub site by synchronizing users across Visitor groups. Or something kind of this. 

SP.File

A new handy method was added for file deletions. Sometimes, when you want to delete a file, but a file is opened by another user in a client application (i.e. for .docx that's Word or Word online), you will receive an error. 

For example below request is supposed to delete a file using REST API:

POST {{siteUrl}}/_api/web/getfilebyserverrelativeurl('/sites/dev/MyLibrary/test.docx')
Accept: application/json;odata=verbose
Content-Type: application/json;odata=nometadata
X-RequestDigest: {{digest}}
X-HTTP-Method: DELETE
If-Match: *

But instead you get an error: 

{
  "error": {
    "code": "-2147018894, Microsoft.SharePoint.SPFileLockException",
    "message": {
      "lang": "en-US",
      "value": "The file /sites/dev/MyLibrary/test.docx is locked for shared use by <user> [membership]."
    }
  }
}

The reason is that the file is opened in a client application and SharePoint prevents deletion. Sometimes a file isn't even opened but was opened before and SharePoint still thinks it is opened and locked.  

Now you can "force" delete that file with a new method DeleteWithParameters

POST {{siteUrl}}/_api/web/getfilebyserverrelativeurl('/sites/dev/MyLibrary/test.docx')/DeleteWithParameters()
Accept: application/json;odata=verbose
Content-Type: application/json;odata=nometadata
X-RequestDigest: {{digest}}

{
    "parameters": {
        "BypassSharedLock": true,
        "ETagMatch": "*"
    }
}

Take a not on BypassSharedLock param, which is true. I haven't found a way to update a file bypassing the shared lock, or move a file. Maybe corresponding methods will be added in the future. 

This is it, as usual, you can explore the full list of changes on your own at API Changelog