Questions tagged [pnp-js]

PnPjs is a collection of fluent libraries for consuming SharePoint, Graph, and Office 365 REST APIs in a type-safe way. You can use it within SharePoint Framework, Nodejs, or any JavaScript project.

PnPjs is a collection of fluent libraries for consuming SharePoint, Graph, and Office 365 REST APIs in a type-safe way. You can use it within SharePoint Framework, Nodejs, or any JavaScript project.

Getting Started

Install the library and required dependencies

npm install @pnp/sp --save

Import the library into your application and access the root sp object

import { sp } from "@pnp/sp";
import "@pnp/sp/webs";
import "@pnp/sp/lists";

// get the list by Id
const list = sp.web.lists.getById("03b05ff4-d95d-45ed-841d-3855f77a2483");

// we can use this 'list' variable to execute more queries on the list:
const r = await list.select("Title")();

// show the response from the server
console.log(r.Title);
146 questions
3
votes
0 answers

SharePoint Online APIs - detect NoScript (DenyAddAndCustomizePages) state?

I'm attempting to query for properties of a SharePoint Online site using the _api method in a SharePoint Framework TypeScript project (https://tenancy.sharepoint.com/sites/classic-example/_api/site) and determine if the site is a NoScript site or…
OmniFace
  • 31
  • 1
2
votes
2 answers

How to configure a spfx extension at runtime like ENV vars?

If i write for example a node express app, i have the opportunity to pass some env vars from the server configuration. Is there an opportunity in SharePoint Online also? As SharePoint Online is a managed service, there's imho no way to do so. Is…
2
votes
1 answer

PnP.Core uploading to Sharepoint folder c# error 'To update this folder, go to the channel in Microsoft Teams'

I have a solution I created a little over a year ago that uses PnP.Core to upload file to a specific folder on SharePoint. It was all well until a couple days ago where that solution started generating error that says To update this folder, go to…
Bonaii
  • 75
  • 6
2
votes
1 answer

How do you remove comments from a specific item of a Sharepoint list?

The delete () function of the IComments interface (PnP) does not delete the comment I select through the index, how can I use it? (@pnp/sp/comments) in this way I get the comments of the item to which I will pass the index, but once I try to use the…
SiCaMa
  • 25
  • 4
2
votes
1 answer

SPFX pnpjs spfi().using(SPFx(this.props.context)) doesn't get web object

i have two client webparts in a page. both of them use pnpjs to retreive list items. the problem is that one webpart correctly loads sp.web while the other doesn't. both use the same code to instantiate the element. this.sp =…
2
votes
1 answer

Unable to connect and get Sharepoint data from C# .Net Core App

While using pnp.Framework in .Net 6 environment. I need authenticated client context to get Sharepoint Data but facing 403forbidden while running context.ExecuteQuery(). I want to use the clientId and clientSecret mode of authentication for getting…
2
votes
1 answer

SPFx & PnPjs People picker issues

Trying to develop a webpart with PnP people picker (in promise) Error: Error making HttpClient request in queryable [400] ::> {"odata.error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"An…
explorer
  • 21
  • 7
1
vote
1 answer

PnPjs: Filtering SharePoint document library by file name results in errors

I am working on a new web part to display a list of files in a SharePoint document library called Medicine files. I want users to be able to filter the files based on different columns, including file names. I am using PnPjs to search for files by…
1
vote
1 answer

Enable the "Make "New Folder" command available?" option with Sharepoint using @pnp/sp

I need to create folder under Site Pages library under SharePoint Online site. I have tried to create the folder programmatically using @pnp/sp library. But it thrown me Access Denied error. New Folder option is missing while click on New. Please…
1
vote
1 answer

How to get the publishing state of a given page?

Currently I'm trying to get some information of the publishing state of a given page. Maybe anybody has an idea for this issue. Thanks in advance To get information about the page I use pnpjs to retrieve the pages list item as follows: const…
ThomasP
  • 35
  • 4
1
vote
1 answer

How to get user department, phoneNumber with PeoplePicker

I am working in SPO (SPFX react js application) and successfully PeoplePicker work, but I am wondering how to get to console.log department and phoneNumber (already can get loginName, id, displayName) MobilePhone in console is undefined. I don't…
jck4real
  • 33
  • 7
1
vote
0 answers

How to integrate react font awesome icon picker in PropertyFieldCollectionData control in SPFx?

I have created SharePoint Framework web part in SharePoint online. I have integrated PropertyFieldCollectionData in that web part. Below is the link for the…
1
vote
1 answer

Unable to copy file from SharePoint different site document library with sp-pnp-js

I need to copy a file from one SharePoint online site document library to another SharePoint online document library under the same tenant. I have used "sp-pnp-js": "^3.0.10" in my solution. Below is my code snippet, // let sourceFIleUrl =…
1
vote
1 answer

TypeError: Cannot read properties of undefined (reading 'pageContext') when using sp pnp v3

I'm using this tutorial to create a webpart using spfx and sp/pnp v3: https://learn.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/guidance/use-sp-pnp-js-with-spfx-web-parts I've also referred to: https://pnp.github.io/pnpjs/getting-started/ Here…
NightTom
  • 418
  • 15
  • 37
1
vote
0 answers

Execute generic Graph call in SPFx with PnP 3

So far I have been using the following to execute a request against the Graph API. import { MSGraphClient } from '@microsoft/sp-http'; const graphClient: MSGraphClient = await context.msGraphClientFactory.getClient(); const…
Jools
  • 135
  • 2
  • 9
1
2 3
9 10