aronhd
aronhd

Reputation: 1

Cannot implement billing (model=B) query param for Teams API in .NET SDK [5.8.0]

Necessary permissions and subscription have been set up in azure, and I have been able to use the correct billing model in postman reqs / powershell invoking an http request:

https://graph.microsoft.com/v1.0/teams/{{team-id}}/channels/getAllMessages?model=B.

However I cannot find any way to do this in the dotnet SDK as the Model property does not exist on the QueryParameters object:

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

The MSND article does not cover how to use the correct billing model in the SDK either.

I cannot find any way to invoke a graph api request using the url directly either (as you can do with the Invoke-GraphRequest cmdlet in the Microsoft.Graph PowerShell module).

I have raised an issue on the GitHub repo.

Has anyone come up against this and found a solution?

EDIT:

I have managed a work around by getting the RequestInformation from the requestBuilder, manually resetting the uri, and then using the client request adapter to send the altered request:

            // 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);

Hopefully MS will properly implement this in the SDK.

Upvotes: 0

Views: 82

Answers (1)

aronhd
aronhd

Reputation: 1

MS have now added the parameter and closed in this issue.

Upvotes: 0

Related Questions