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

AddAvailableContentTypeFromHubAsync throws Exception, even on success #1175

Closed
1 task done
web265p3 opened this issue May 10, 2023 · 2 comments
Closed
1 task done
Assignees
Labels
area: model 📐 Related to the core SDK models bug Something isn't working

Comments

@web265p3
Copy link

web265p3 commented May 10, 2023

Category

  • Bug

Describe the bug

When I call the function AddAvailableContentTypeFromHubAsync on a list or site, a MicrosoftGraphServiceException is thrown.
For example the following lines throw this exception:

 var contentType = _pnpContext.ContentTypeHub.ContentTypes.AsRequested().FirstOrDefault(ct => ct.StringId == contentTypeId);
                await _pnpContext.Web.ContentTypes.AddAvailableContentTypeFromHubAsync(contentType.StringId, new AddContentTypeFromHubOptions { WaitForCompletion = true });
                await list.ContentTypes.LoadAsync();
                await list.ContentTypes.AddAvailableContentTypeFromHubAsync(contentType.StringId, new AddContentTypeFromHubOptions { WaitForCompletion = true });

The Exception itself does not contain any data - also no error message. Just a status code of 202 is shown.

When I inspect the traffic with fiddler, I can see multiple graph calls that are checking if the job has finished. Those calls are (like expected) continued until the graph returns a success.
Then the above exception is thrown.

Expected behavior

No Exception anymore if AddAvailableContentTypeFromHubAsync is called successfully.

Environment details (development & target environment)

.Net 6, Visual Studio 2022

  • SDK version: Pnp.Core 1.9.0
  • OS: Windows 11
  • Framework: .Net 6
@jansenbe
Copy link
Contributor

Thanks for reporting this issue @web265p3 , I'll have a look.

@jansenbe jansenbe self-assigned this May 10, 2023
@jansenbe jansenbe added question Further information is requested area: model 📐 Related to the core SDK models bug Something isn't working and removed question Further information is requested labels May 10, 2023
@jansenbe
Copy link
Contributor

@web265p3 : I've reproduced this issue and fixed it. The fix will be part of the next nightly build (version 1.9.43 or higher). Closing this issue now, if you still have this problem when using the next nightly then please re-open or create a new issue with additional details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: model 📐 Related to the core SDK models bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants