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]: Microsoft.Graph 5.4.0 generates invalid request Uris for GetDirectRoutingCallsWithFromDateTimeWithToDateTime #1787

Closed
sopelt opened this issue Mar 29, 2023 · 6 comments · Fixed by #1870

Comments

@sopelt
Copy link

sopelt commented Mar 29, 2023

Describe the bug
When calling CallRecordsGetDirectRoutingCallsWithFromDateTimeWithToDateTime the current Microsoft.Graph SDK/client generates a wrong request URL (resulting in HTTP 404) and invalid filter parameter format (resulting in HTTP 404 as well as the route doesn't seem to match). This is a followup/related to #1443 and potentially microsoft/OpenAPI.NET.OData#262 and I hope @andrueastman will have a look at this as well.

As far as I can tell this did not work yet in any dotnet graph SDK version.

To Reproduce

var response = await GraphServiceClient.Communications.CallRecords.CallRecordsGetDirectRoutingCallsWithFromDateTimeWithToDateTime(fromDateTime, toDateTime).GetAsync();

Expected behavior
Call records are being returned.

Screenshots
image

Client version
https://www.nuget.org/packages/Microsoft.Graph/5.4.0

Desktop (please complete the following information):

  • Win11
  • .NET 6.0

Workaround

The following snippet shows how to override the url template and encode the parameters in the working format:

var dateFormat = "yyyy-MM-dd";

var parameters = new Dictionary<string, object>
{
    { "fromDateTime", fromDateTime.ToString(dateFormat, CultureInfo.InvariantCulture) },
    { "toDateTime", toDateTime.ToString(dateFormat, CultureInfo.InvariantCulture) }
};

var requestBuilder = new CallRecordsGetDirectRoutingCallsWithFromDateTimeWithToDateTimeRequestBuilder(parameters, GraphServiceClient.RequestAdapter);
var requestInfo = requestBuilder.ToGetRequestInformation();
requestInfo.UrlTemplate = "{+baseurl}/communications/callRecords/getDirectRoutingCalls(fromDateTime={fromDateTime},toDateTime={toDateTime}){?%24top,%24skip,%24search,%24filter,%24count}";
var response = await GraphServiceClient.RequestAdapter.SendAsync(requestInfo, GetDirectRoutingCallsWithFromDateTimeWithToDateTimeResponse.CreateFromDiscriminatorValue);
@andrueastman
Copy link
Member

Related to microsoft/OpenAPI.NET.OData#365

@baywet

This comment was marked as outdated.

@baywet
Copy link
Member

baywet commented Mar 30, 2023

After further investigations:

GET https://graph.microsoft.com/v1.0/communications/callRecords/microsoft.graph.callRecords.getDirectRoutingCalls(fromDateTime=2023-03-25,toDateTime=2023-03-29)?$whatif

{
    "Description": "Execute HTTP request",
    "Uri": "https://plat.teams.microsoft.com/communications/callRecords/microsoft.graph.callRecords.getDirectRoutingCalls(fromDateTime=2023-03-25,toDateTime=2023-03-29)",
    "HttpMethod": "GET",
    "TargetWorkloadId": "Microsoft.IC3.DataPlatform"
}
GET https://graph.microsoft.com/v1.0/communications/callRecords/getDirectRoutingCalls(fromDateTime=2023-03-25,toDateTime=2023-03-29)?$whatif

{
    "Description": "Execute HTTP request",
    "Uri": "https://plat.teams.microsoft.com/communications/callRecords/microsoft.graph.callRecords.getDirectRoutingCalls(fromDateTime=2023-03-25,toDateTime=2023-03-29)",
    "HttpMethod": "GET",
    "TargetWorkloadId": "Microsoft.IC3.DataPlatform"
}
GET https://graph.microsoft.com/v1.0/communications/callRecords/callRecords.getDirectRoutingCalls(fromDateTime=2023-03-25,toDateTime=2023-03-29)?$whatif

{
    "Description": "Execute HTTP request",
    "Uri": "https://plat.teams.microsoft.com/communications/callRecords('callRecords.getDirectRoutingCalls(fromDateTime=2023-03-25,toDateTime=2023-03-29)')",
    "HttpMethod": "GET",
    "TargetWorkloadId": "Microsoft.IC3.DataPlatform"
}

So it's effectively AGS messing up the request. We should probably open an ICM on them.

@andrueastman
Copy link
Member

Thanks for this @baywet

Taking a look at the URI's above, it looks like the first two generate the same URI with the full namespace and with the whole namespace stripped.
https://plat.teams.microsoft.com/communications/callRecords/microsoft.graph.callRecords.getDirectRoutingCalls(fromDateTime=2023-03-25,toDateTime=2023-03-29)

While the third one generates
https://plat.teams.microsoft.com/communications/callRecords('callRecords.getDirectRoutingCalls(fromDateTime=2023-03-25,toDateTime=2023-03-29)')

As the metadata does not have an alias for the microsoft.graph.callRecords namespace I suspect that it might be an error with the indiscriminate stripping of the microsoft.graph prefix for methods.

image

@baywet
Copy link
Member

baywet commented Mar 30, 2023

ah, so there's no alias being defined? then yes, it's an issue of the conversion process. Thanks for calling this out.

@andrueastman
Copy link
Member

This would be the same for #1691 as the microsoft.graph.security namespace also does not have an alias.

@ghost ghost locked as resolved and limited conversation to collaborators Jun 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants