0

I got an error when I have Contribute permission for site:

Access denied. You do not have permission to perform this action or access this resource.

my code is uploading the file and then trying to change content type of that file, uploading code works fine, but changing content type throws an exception.

Here is the code I am using:

var file = context.Web.GetFileByServerRelativeUrl(serverRelativeUrl);
context.Load(file);
context.ExecuteQuery(); // excuted fine 

file.ListItemAllFields["ContentTypeId"] = attachment.CType.Id;
file.ListItemAllFields.Update();
file.ListItemAllFields.SystemUpdate();
file.Update();
context.Load(file);
context.ExecuteQuery(); // Exception here

any idea for solving this issue?

0

You are doing SystemUpdate, you need SiteCollection Administrator Permissions here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.