Friday 17 June 2016

SharePoint Online: Write User Profile Properties with REST API

In my previous posts, we saw how to Set user profile properties using JSOM & JavaScript and Set another user's profile properties with CSOM

Now, here are some code snippets I have put together to set SharePoint User Profile properties with the SharePoint REST API

  • This code only works with SharePoint Online at this time.
  • Can be used to set single value as well as multi value user profile properties.
  • Can be used to set default (OOB) as well as custom user profile properties.

1) Set Single Value User Profile property with REST API:

2) Set Mutli Value User Profile property with REST API:

Hope you find this useful!

Wednesday 1 June 2016

SharePoint Online: Get UserProfile Properties with REST API Batching

In my previous post SharePoint 2013: Get UserProfile Properties with REST APIwe saw how to fetch SharePoint UserProfile properties with the REST API.

The only thing missing in that post was, at the time there was no way to get Multiple UserProfile Properties for a Specific User i.e. if you had an account name of a user and wanted to fetch multiple custom or default UserProfile properties, you could not do that in a single REST call. You would have to resort to either making multiple REST calls using the GetUserProfilePropertyFor function, or you would have to use the JavaScript Client Object Model (JSOM)

When I wrote that post, SharePoint Online did not support REST API batching. Since then, it has been implemented and as a result we can get multiple Custom/OOB User Profile properties in a single REST call.

Here is my code showing how to do it:

Here are some other great resources on SharePoint REST API Batching:

Batch Processing (OData Version 3.0)

Part 1 - SharePoint REST API Batching - Understanding Batching Requests

Make batch requests with the REST APIs

Thanks for reading!