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

Getting default site groups generating invalid request #1206

Closed
1 task done
JakeStanger opened this issue Jun 15, 2023 · 3 comments
Closed
1 task done

Getting default site groups generating invalid request #1206

JakeStanger opened this issue Jun 15, 2023 · 3 comments

Comments

@JakeStanger
Copy link

JakeStanger commented Jun 15, 2023

Category

  • Bug

Describe the bug

Attempting to get the default associated groups for a web incorrectly creates a getbyid URL, which then contains an unresolved token for the ID.

This affects AssociatedOwnerGroup, AssociatedMemberGroup, and AssociatedVisitorGroup.

PnP.Core: Unresolved tokens found in API call 
https://<tenant>.sharepoint.com/sites/test/_api/Web/sitegroups/getbyid({Id})

Steps to reproduce

  1. Run code snippet below
  2. Experience error
var context = await _contextFactory.CreateAsync(new Uri("https://<tenant>.sharepoint.com/sites/test"));

// using `context.Web` directly and omitting this makes no difference.
var web = await context.Web.GetAsync();
var members = await web.AssociatedVisitorGroup.GetAsync();

Expected behavior

The generated URL correctly points to the associated group, and the data is fetched without error.

eg:

/sites/test/_api/web/associatedMemberGroup

Environment details (development & target environment)

  • SDK version: 1.9.72-nightly
  • OS: Windows 11, and whatever Azure Functions runs on
  • SDK used in: Azure Functions
  • Framework: .NET 6
  • Tooling: Jetbrains Rider
@jansenbe
Copy link
Contributor

@JakeStanger : can you try the below:

var web = await context.Web.GetAsync(p => p.AssociatedVisitorGroup.QueryProperties(p=>p.Users), p => p.AssociatedMemberGroup.QueryProperties(p => p.Users));

foreach(var user in web.AssociatedMemberGroup.Users.AsRequested())
{

}

@JakeStanger
Copy link
Author

Have just tested and it works as expected. Getting other properties of the group (eg its ID) also works this way.

p.AssociatedOwnerGroup.QueryProperties(p => p.Users, p => p.Id)

@JakeStanger
Copy link
Author

I appreciate the workaround, but I disagree that the issue should be closed, since getting the properties directly (as in my repro) still causes an error. I'd argue if this is 'intended', at the very least this should be documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants