pnp / pnpcore

The PnP Core SDK is a modern .NET SDK designed to work for Microsoft 365. It provides a unified object model for working with SharePoint Online and Teams which is agnostic to the underlying API's being called
https://aka.ms/pnp/coresdk/docs
MIT License
296 stars 190 forks source link

Cannot update web Title (Name) #1522

Closed EdAlexander closed 1 week ago

EdAlexander commented 1 week ago

Category

Describe the bug

Cannot rename a site/web.

Steps to reproduce

` var caseWeb = await context2.Web.GetAsync(w => w.Title, w => w.Description, w => w.Url, w => w.MasterUrl);

if (caseWeb.Title != SelectedCase.caseName)
    {
        caseWeb.Title = SelectedCase.caseName;
        await caseWeb.UpdateAsync();
    }`

Expected behavior

web title should be updated

EdAlexander commented 1 week ago

Solved... ` var siteProperties = await context2.GetSiteCollectionManager().GetSiteCollectionPropertiesAsync(caseWeb.Url);

siteProperties.Title = SelectedCase.caseName;

await siteProperties.UpdateAsync(); `

jansenbe commented 1 week ago

If the user in question is a tenant admin but does not have the proper permissions on the site collection to make the changes as a site user there will be a permission denied error. Using the admin api's indeed is the solution here.