SPFx webpart with MS Graph and PnPjs: step by step guide

So you want to build an SPFx webpart which uses MS Graph API through PnPjs. Here is step by step guide on how to do that.

A few months ago I wrote a similar post, however, things were changed, some things were simplified a lot, that’s why this is a revisited guide. Also, I’ve addressed some additional steps here. The source code sample is available at GitHub.

Prerequisites

  • SPFx >= 1.6
  • PnPjs >= 1.2.4

1. Scaffold SPFx webpart solution with React

This step is pretty self-explanatory, simply run yo @microsoft/sharepoint, select React, give your webpart a name, do not change other defaults asked by yeoman.

More...

How to create SharePoint Online add-in with ASP.NET Core 2.1

While support of .NET Core for SharePoint CSOM libraries on its own way (still no ETA), you can create a SharePoint add-in with ASP.NET Core 2.1 today. Of course, it adds some inconveniences, but at least you can target the latest version of ASP.NET. I’ve created a sample project at GitHub here so you can easily try it. This post describes how to configure everything to run it.

First of all, a few drawbacks worth mentioning:

- you can’t use F5 experience in Visual Studio for convenient debugging. Instead, you should manually upload your app into a site and attach Visual Studio to running web application.

- you can’t target a project to netcoreapp. Obviously you can’t do it because SharePoint CSOM for .NET Core is not available yet. That’s why you have to retarget your project to .NET Framework instead. Which means that you lose cross platform feature. If that’s essential thing for you, then you should wait for official .NET Core support. 

- solution described here only works for SharePoint Online. On-premises is a completely different story and out of the scope of the post

Let’s get started. More...

What’s new and what’s changed in SharePoint Online REST API in October 2018

It’s November and it’s time to review changes in SharePoint REST API in October with help of SharePoint RESE API Explorer. As usual I have to put below caution:

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

With REST API explorer you can navigate between different endpoints, explore their structure, methods, classes and parameters. REST API explorer uses _api/$metadata endpoint to get the REST API data, parses it and presents in tree view format. REST API explorer also stores historical $metadata results in Azure storage making it possible to compare $metadata results we have today and month ago. More...

What’s new and what’s changed in SharePoint Online REST API in September 2018

A few months ago I’ve created a site, where you can explore SharePoint REST API - SharePoint REST API Metadata Explorer. With REST API explorer you can navigate between different endpoints, explore their structure, methods, classes and parameters. REST API explorer uses _api/$metadata endpoint to get the REST API data, parses it and presents in tree view format. REST API explorer also stores historical $metadata results in Azure storage making it possible to compare $metadata results we have today and month ago. I’ve added a new section to REST API explorer called SharePoint REST API Change Log. With change log you can explore what was changed in SharePoint APIs in the last few months. More...

Azure DevOps stories. Run PnP-PowerShell scripts in your build with ease!

A few times ago I wrote a post on how to run PnP-PowerShell in your Azure DevOps build. Described method is a bit inconvenient (hello @waldekm :)), because you have to setup a code, which automatically installs PnP-PowerShell module. You should repeat it for every PowerShell script step. What if I want just put my PnP-PowerShell code in file, run it and that's it?

To make things easier, I've created a custom build\release step for Visual Studio Team Services (now Azure DevOps) called (guess how) - PnP-PowerShell. This step significantly simplifies the way you run PnP-PowerShell commands in Azure DevOps. More...