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

[Client bug]: ...Channels.GetAllMessages cannot implement billing (model=B) #1979

Closed
Aron-HD opened this issue Jun 20, 2023 · 2 comments · Fixed by microsoftgraph/msgraph-metadata#370

Comments

@Aron-HD
Copy link

Aron-HD commented Jun 20, 2023

Describe the bug
I can use the correct billing method with a query param in an http request, but there is no way to do this in the SDK: https://graph.microsoft.com/v1.0/teams/{{team-id}}/channels/getAllMessages?model=B.

To Reproduce
Steps to reproduce the behavior:

            var res = await _graphClient.Teams[teamId].Channels.GetAllMessages.GetAsync((rq) =>
            {
                rq.QueryParameters.Top = 200;
                rq.QueryParameters.Model = "B";
            });

Expected behavior

Screenshots
image

Client version
5.8.0

Desktop (please complete the following information):

  • OS: Windows-11
  • Browser [e.g. chrome, safari]: N/A
  • Version [e.g. 22]: N/A

Additional context

@ghost ghost added the Needs: Triage label Jun 20, 2023
@Aron-HD
Copy link
Author

Aron-HD commented Jun 21, 2023

I have managed a work around with:

            // get the requestInfo from the builder
            var req = _graphClient.Teams[teamId].Channels.GetAllMessages.ToGetRequestInformation();

            // manually set the URI with the billing parameter as a work around.
            req.URI = new Uri($"https://graph.microsoft.com/v1.0/teams/{teamId}/channels/getAllMessages()?model=B&%24top=200");

            // copy the error mapping from the builder
            var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
                {"4XX", ODataError.CreateFromDiscriminatorValue},
                {"5XX", ODataError.CreateFromDiscriminatorValue},
            };

            var res = await _graphClient.RequestAdapter.SendAsync(req, GetAllMessagesResponse.CreateFromDiscriminatorValue, errorMapping);

This could potentially be a simple fix:

namespace Microsoft.Graph.Teams.GetAllMessages {
    /// <summary>
    /// Provides operations to call the getAllMessages method.
    /// </summary>
    public class GetAllMessagesRequestBuilder : BaseRequestBuilder {
        /// <summary>
        /// Instantiates a new GetAllMessagesRequestBuilder and sets the default values.
        /// </summary>
        /// <param name="pathParameters">Path parameters for the request</param>
        /// <param name="requestAdapter">The request adapter to use to execute the requests.</param>
        public GetAllMessagesRequestBuilder(Dictionary<string, object> pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/teams/getAllMessages(){?model,%24top,%24skip,%24search,%24filter,%24count,%24select,%24orderby}", pathParameters) {
        }
        /// <summary>
        /// Instantiates a new GetAllMessagesRequestBuilder and sets the default values.
        /// </summary>
        /// <param name="rawUrl">The raw URL to use for the request builder.</param>
        /// <param name="requestAdapter">The request adapter to use to execute the requests.</param>
        public GetAllMessagesRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/teams/getAllMessages(){?model,%24top,%24skip,%24search,%24filter,%24count,%24select,%24orderby}", rawUrl) {
        }
        
        //...

        /// <summary>
        /// Invoke function getAllMessages
        /// </summary>
        public class GetAllMessagesRequestBuilderGetQueryParameters {
            /// <summary>Include billing model</summary>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
            [QueryParameter("model")]
            public string? Model { get; set; } // "A" | "B"
#nullable restore
#else
            [QueryParameter("model")]
            public string Model { get; set; } // "A" | "B"
#endif
            /// <summary>Include count of items</summary>
            [QueryParameter("%24count")]
            public bool? Count { get; set; }
            
            //...
        }
}

@andrueastman
Copy link
Member

Depends on microsoftgraph/msgraph-metadata#314

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

Successfully merging a pull request may close this issue.

2 participants