7

OK, we have got SharePoint framework now, but how do we access the data in SharePoint programmatically? What API do we use? Did Microsoft introduce any new API? And can we still use the CSOM and REST?

I am not talking about which framework to use, like Angular or REACT. Thank you.

3 Answers 3

6

For REST-queries, you should use the SpHttpClient class. JSOM is no longer being maintained, so avoid it for now.

For "back-end" (C#-code), CSOM is your only option. I usually deploy some CSOM code by using an Azure function and loading the SharePointPnPCoreOnline library. It's easy and fast to set up. The main benefit of the PnP library is the ClientContext.ExecuteQueryRetry()-function which has a built in retry-strategy if your requests get throttled.

5

In SPFx you get page context automatically. With page context you can get Site context and all the elements like list, libraries. In SPFx we have to use javascript frameworks like Node.js, React, Angular. You have to get data from SP using REST calls with using one of these javascript frame works. Hope this helps you.

2

There are multiple options you can use in SPFx:

  • SPHttpClient class to make REST requests to SharePoint REST API
  • You can also load any JSOM files to the page (by default, they're not loaded on modern pages). This could be helpful if you need to perform some operations that are unavailable in REST
  • GraphHttpClient or AadHttpClient to perform MS Graph requests
  • PnP libs to perform SharePoint REST calls using JavaScript objects

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.