UNABLE to Add Site and/or List fields #1065
Unanswered
icooooooooooooo
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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.
Beta Was this translation helpful? Give feedback.
All reactions