-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
What type of issue is this?
Question
What SharePoint development model, framework, SDK or API is this about?
💥 SharePoint Framework
Target SharePoint environment
SharePoint Online
What browser(s) / client(s) have you tested
- 💥 Internet Explorer
- 💥 Microsoft Edge
- 💥 Google Chrome
- 💥 FireFox
- 💥 Safari
- mobile (iOS/iPadOS)
- mobile (Android)
- not applicable
- other (enter in the "Additional environment details" area below)
Additional environment details
IDE - MS Visual studio
PnP framework - latest
SharePoint version - Online
Issue description
Hi all,
I hope this is where such questions are to be asked.
I am doing a proof of concept, where I need to programmatically add a file with the corresponding metadata(All custom columns).
I am capable of adding metadata into manually created fields, but I cannot add the Fields via the PnP Framework. I used this for reference - https://pnp.github.io/pnpcore/using-the-sdk/fields-add.html
Once I try to create the new field:
IField myField = await myList.Fields.AddTextAsync("Test New Field", new FieldTextOptions()
{
InternalName = "Test New Field",
Group = "Custom Fields",
AddToDefaultView = true,
MaxLength = 30
});
I am receiving an error:
Unhandled exception. HttpResponseCode: 403
Code: System.UnauthorizedAccessException
Message: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
I can confirm that I can create manually the fields and in both the Azura Portal and Entra I am with the highest possible admin type. Further I am the owner of the Site and List, so I would guess I am not building the myList variable properly. I am reaching to this conclusion as in the article itself the myList is simply used and not explained.
What I use for myList in my code is context.Web.Lists.GetByTitle("Test List"); and the context is enough for all other actions.
Please advise.