Posts

Showing posts with the label SharePoint REST

Disable list view selection for users on SharePoint Online using SPFx Application Extension

Image
 Recently we ran into an issue on SharePoint Online that user should be able to see only their records in a list and not otehrs. So we had updated the default list view filter with Employee equal to [Me].  We have also created a view "Admin" with no filter so admins can see all records. However, the view selection is still enabled as they have View permission and hence the users can switch to Admin views and see all records, see below screenshot: So to solve this issue, we created a very simple SPFx Application customizer extension such that it hides the entire list comand bar for normal users, and shows it for only site admins. See the end result for Site admins and Normal users: Open the node.js command prompt and start eith the yeoman scaffolding: Select the type of client-side component as Exension Select the type of extension to be Application Customizer Open the solution in VS Code Create a new CSS file in this path: src > extensions > appExtensionDemo > mysty...

SharePoint Get list items from List view- REST API

In the below code snippet, call the  getListViewItems method by passing the weburl, list title and the viewname. function   executeJson ( url ,  method ,  headers ,  payload ) {      method  =  method  ||  'GET' ;      headers  =  headers  || {};      headers [ "Accept" ] =  "application/json;odata=verbose" ;      if  ( method  ==  "POST" ) {          headers [ "X-RequestDigest" ] =  $ ( "#__REQUESTDIGEST" ). val ();     }      var   ajaxOptions  = {          url :   url ,          type :   method ,          contentType :   "application/json;odata=verbose" ,   ...

SharePoint Get list items by CAML query - REST API

 Below is the javascript code for getting list items by CAML Query. function   executeJson ( url ,  method ,  headers ,  payload ) {      method  =  method  ||  'GET' ;      headers  =  headers  || {};      headers [ "Accept" ] =  "application/json;odata=verbose" ;      if  ( method  ==  "POST" ) {          headers [ "X-RequestDigest" ] =  $ ( "#__REQUESTDIGEST" ). val ();     }      var   ajaxOptions  = {          url :   url ,          type :   method ,          contentType :   "application/json;odata=verbose" ,          headers : ...

SharePoint Online (O365) OAuth Authentication | Authorizing REST API calls against SharePoint Online Site | Get Access token from SharePoint Online | Set up OAuth for SharePoint Online Office 365

Image
Here is my most awaited post on how to set up OAuth for SharePoint Online so that we can authorize REST API calls to the SharePoint site to retrieve data and manipulate the site data. The steps going to be easy and I will demonstrate along with screenshots and examples with the Google PostMan RESTClient . I have explained the steps below which follows the OAuth 2.0 protocol. All the steps are straight forward, but constructing the URLs are little tricky! Below are the detailed steps: 1.  Register an app in SharePoint ·          Navigate to https://your_site_name.com/_layouts/15/appregnew.aspx ·          Click Generate for Client Id and Client Secret. ·          Give a name for the app, fill in the app domain (ex: www.google.com , www.salesforce.com ). Enter the Redirect URL, important here is when entering redirect url, it should be https ...