Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed an issue where adding items to the root site collection resulted in a 404 #470

Merged
merged 1 commit into from
Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/sdk/PnP.Core/Model/SharePoint/Core/Internal/ListItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ public ListItem()
};
AddApiCallHandler = async (keyValuePairs) =>
{
var parentList = Parent.Parent as List;
// sample parent list uri: https://bertonline.sharepoint.com/sites/modern/_api/Web/Lists(guid'b2d52a36-52f1-48a4-b499-629063c6a38c')
var parentListUri = parentList.GetMetadata(PnPConstants.MetaDataUri);
Expand All @@ -99,7 +98,7 @@ public ListItem()
string serverRelativeUrl = null;
if (string.IsNullOrEmpty(parentListTitle) || string.IsNullOrEmpty(parentListUri) || !parentList.IsPropertyAvailable(p => p.TemplateType))
{
// Fall back to loading the rootfolder propery if we can't determine the list name
// Fall back to loading the RootFolder property if we can't determine the list name
await parentList.EnsurePropertiesAsync(p => p.RootFolder).ConfigureAwait(false);
serverRelativeUrl = parentList.RootFolder.ServerRelativeUrl;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ namespace PnP.Core.Model.SharePoint
{
internal static class ListMetaDataMapper
{

internal static string MicrosoftGraphNameToRestEntityTypeName(string microsoftGraphListName, ListTemplateType listTemplateType)
{
if (listTemplateType == ListTemplateType.UserInformation)
Expand All @@ -23,7 +22,7 @@ internal static string MicrosoftGraphNameToRestEntityTypeName(string microsoftGr
}

// Build the name
string entityNameToUse = $"{entityName.ToString().Replace(" ", "")}{(isList ? "List" : "")}";
string entityNameToUse = $"{entityName.Replace(" ", "")}{(isList ? "List" : "")}";
// Ensure first character is upper case
entityNameToUse = entityNameToUse.First().ToString().ToUpper() + entityNameToUse.Substring(1);

Expand All @@ -32,6 +31,7 @@ internal static string MicrosoftGraphNameToRestEntityTypeName(string microsoftGr

internal static string RestEntityTypeNameToUrl(Uri pnpContextUri, string restEntityTypeName, ListTemplateType listTemplateType)
{
var contextUrl = pnpContextUri.ToString().TrimEnd('/');
(bool isList, _, bool isCatalog) = DetectListType(listTemplateType);

// Translate special chars back to their regular values
Expand All @@ -52,17 +52,17 @@ internal static string RestEntityTypeNameToUrl(Uri pnpContextUri, string restEnt

// Drop List suffix
listUrl = listUrl.Substring(0, listUrl.Length - 4);
return $"{pnpContextUri}/lists/{listUrl}";
return $"{contextUrl}/lists/{listUrl}";
}
else if (isCatalog)
{
// catalog
return $"{pnpContextUri}/_catalogs/{listUrl}";
return $"{contextUrl}/_catalogs/{listUrl}";
}
else
{
// library
return $"{pnpContextUri}/{listUrl}";
return $"{contextUrl}/{listUrl}";
}
}

Expand Down Expand Up @@ -118,8 +118,5 @@ internal static (bool isList, bool isLibrary, bool isCatalog) DetectListType(Lis

return (isList, isLibrary, isCatalog);
}



}
}