Closed ludes2 closed 6 months ago
PnPjs is a proxy to the SharePoint REST APIs and as such we cannot speak for what those APIs return. If you verify (by looking at the network console) that the payload has -1 for that value then that is the only solution we can provide unless, as you suggest, you switch to Graph endpoint. You could try submitting an issue to sp-dev-docs but I'm going to tell you that Microsoft as an organization wants you to use Graph so that's the answer I'm fairly sure they're going to give you. If you find that the payload does have a different value and it's getting corrupted in some way then please let us know.
I am mostly sure that it is -1 because there is not defined SharePoint PrincipalId. This would be the integer id for an sp user or group. If you are finding a security group it must not have an existing SP Principal ID or maybe can't - 🤷♂️.
If you resolve a user do you get an id?
We have decided to use the GRAP API, thank you for the quick responses. I will mark the issue as resolved.
This issue is locked for inactivity or age. If you have a related issue please open a new issue and reference this one. Closed issues are not tracked.
What version of PnPjs library you are using
3.x
Minor Version Number
3.23
Target environment
SharePoint Framework
Additional environment details
I'm using PnP/js version 3.23 and working in SPFX Version 1.15.2
Question/Request
I am currently working on a SPFX project and have encountered an issue. I have multiples Azure AD Security Groups that are assigned to a SharePoint Default Group. In order to set the correct roleAssignments, I need to obtain the Principal ID of a specific Security Group. However, when I search for the Principal, I am able to find it, but the ID is always -1. I am unsure if this is a bug or if there is a way to resolve this issue. While I am aware that using the Graph API is a possible solution, we would prefer to use the SharePoint REST API as our first option.
my Code: