SharePoint Rest service exception produced when trying to connect to SharePoint site using a different case (lower versus upper) in the URL.
See original GitHub issueCategory
- Bug
Describe the bug
If I have a site in SharePoint online that has capital letters in the URL
https://mytenant.sharepoint.com/sites/TEST-MixedCase
And I try to use a different case (say lower case)
https://mytenant.sharepoint.com/sites/test-mixedcase
The code throws an exception (SharePoint Rest service exception)
at PnP.Core.Services.BatchClient.ProcessSharePointRestBatchResponseContent(Batch batch, String batchResponse)
at PnP.Core.Services.BatchClient.<ProcessSharePointRestBatchResponse>d__48.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
at PnP.Core.Services.BatchClient.<ExecuteSharePointRestBatchAsync>d__46.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
at PnP.Core.Services.BatchClient.<ExecuteBatch>d__37.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
at PnP.Core.Services.PnPContext.<ExecuteAsync>d__86.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
at PnP.Core.QueryModel.DataModelQueryService`1.<ExecuteQueryAsync>d__9.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at PnP.Core.QueryModel.BaseQueryProvider.<CastTask>d__9`1.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at PnP.Core.QueryModel.BaseDataModelExtensions.<BaseLinqGetAsync>d__11`1.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at PnP.Core.Model.SharePoint.ListCollection.<GetByTitleAsync>d__8.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Demo.AzureFunction.GetSiteDocuments.<Run>d__2.MoveNext() in C:\Projects\Demo.AzureFunction\GetSiteDocuments.cs:line 36
Steps to reproduce
- Create a site in SharePoint online named “TEST-MixedCase”. Note the URL should be “/sites/TEST-MixedCase”
- Use the following code to create a context and the try to get list details.
Uri siteUrl = new Uri("https://mytenant.sharepoint.com/sites/test-mixedcase");
using (var pnpContext = await pnpContextFactory.CreateAsync(siteUrl))
{
try
{
IList sharedDocuments = await pnpContext.Web.Lists.GetByTitleAsync("Documents", l => l.RootFolder);
}
catch (Exception ex)
{
return new BadRequestObjectResult(new { message = ex.Message });
}
}
Expected behavior
The case of a URL should not matter when connecting to a SharePoint site.
Environment details (development & target environment)
- SDK version: 0.3.34-preview3
- OS: Windows 10
- SDK used in: Azure Function v3
- Framework: .NET Core v3.1
- Browser(s): N/A]
- Tooling: Visual Studio 2019
- Additional details:
Thanks for your contribution! Sharing is caring.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Sharepoint Site URL issue
SharePoint's URL is not case sensitive, which means either you use upper or lower case in the URL, it should return the same...
Read more >Error when using SharePoint REST API to create modern ...
I'm trying to use the SharePoint REST API's to create a modern SharePoint site collection in SharePoint Online.
Read more >cannot access specific team site using share-point rest apis
for that I have created a custom site using web interface. Name called: TeamSite_ForB. following is the REST endpoint url I'm trying to...
Read more >Error when an external user accepts a SharePoint Online ...
Click the gear icon for the Settings menu, and then click Site settings. In the Users and Permissions section, click People and groups....
Read more >Get to know the SharePoint REST service
Basics of using the SharePoint REST service to access and update SharePoint data, using the REST and OData web protocol standards.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Docs are updated to reflect the need to provide url’s with the correct case: https://pnp.github.io/pnpcore/articles/consumer/readme.html
Just https://pnp.github.io/pnpcore/