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

Unable to set QueryParamters/Format #2465

Closed
GrahamSnee opened this issue Apr 29, 2024 · 4 comments
Closed

Unable to set QueryParamters/Format #2465

GrahamSnee opened this issue Apr 29, 2024 · 4 comments
Labels

Comments

@GrahamSnee
Copy link

Describe the bug

I am wanting to use the GraphServiceClient to get the reports GetM365AppUserDetailWithPeriod. I want to use the format of the return to be in JSON, so using the example from the MS documents I have tried to pass the requestConfiguration query parameters format, but the code will not compile. The complier indicates a missing using statement, but the code matches the examples. (https://learn.microsoft.com/en-us/graph/api/reportroot-getm365appplatformusercounts?view=graph-rest-1.0&tabs=csharp)

Expected behavior

The code to compile, or documents be updated to reflect required usings within the examples

How to reproduce

Create a simple app and add the code

// Code snippets are only available for the latest version. Current version is 5.x

// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Reports.GetM365AppPlatformUserCountsWithPeriod("{period}").GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Format = "application/json";
});

SDK Version

nuget package 5.49.0

Latest version known to work for scenario above?

Unkownn

Known Workarounds

None

Debug output

Compiler Error CS1061 'DefaultQueryParameters' does not contain a definition for 'Format' and no accessible extension method 'Format' accepting a first argument of type 'DefaultQueryParameters' could be found (are you missing a using directive or an assembly reference?)

Configuration

Windows 11

Other information

No response

@andrueastman
Copy link
Member

Thanks for raising this @GrahamSnee

This is related to the metadata that generates the SDK(created microsoftgraph/msgraph-metadata#616 for this.)

In the meantime, you can probably customize your response as below by using the WithUrl method.

            var urlString = graphClient.Reports.GetM365AppPlatformUserCountsWithPeriod("{period}").ToGetRequestInformation().URI.OriginalString;
            urlString += "?$format=application/json";//append the query parameter

            var responseStream = await graphClient.Reports.GetM365AppPlatformUserCountsWithPeriod("").WithUrl(urlString).GetAsync();

@andrueastman andrueastman removed the status:waiting-for-triage An issue that is yet to be reviewed or assigned label May 2, 2024
@GrahamSnee
Copy link
Author

I have tried this, but the client thrown an exception stating ‘{"Message":"JSON format is not supported."}’

@andrueastman
Copy link
Member

Thanks for getting back to this. It looks like the API may not support the json type for this scenario(Which suggests that the documenation is invalid/incorrect).

Are you by any chance able to replicate this using the Graph explorer?

@GrahamSnee
Copy link
Author

With Graph explorer it does not work, but neither does the getting of the information in CSV work either

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

No branches or pull requests

2 participants