Skip to content

Batch Request & Azure App Service #2681

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

Closed
PatrickKelley2112 opened this issue Sep 25, 2024 · 4 comments
Closed

Batch Request & Azure App Service #2681

PatrickKelley2112 opened this issue Sep 25, 2024 · 4 comments
Labels
Status: No recent activity status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close type:bug A broken experience

Comments

@PatrickKelley2112
Copy link

PatrickKelley2112 commented Sep 25, 2024

Describe the bug

I have a batch request that works flawlessly when I'm debugging on IIS Express, but as soon as I publish to an Azure App Service the batch returns error 400 for every request in the batch.

The max number of user calendars I'm requesting is around 10, but it fails even if I just add 1 to the batch. I can pull individual calendars using CalendarView.GetAsync locally or on the app service so it's definitely something with the batch request.

Expected behavior

Returns user calendar events.

How to reproduce

 foreach (var user in users)
 {
     var eventRequest = graphClient.Users[user.UserPrincipalName].CalendarView
                    .ToGetRequestInformation(requestConfiguration =>
                    {
                        requestConfiguration.QueryParameters.StartDateTime = startTime.ToString();
                        requestConfiguration.QueryParameters.EndDateTime = endTime.Value.ToString();
                    });

     eventRequests.Add(await batchRequestContent.AddBatchRequestStepAsync(eventRequest, user.UserPrincipalName));

 }
 
 var returnedResponse = await graphClient.Batch.PostAsync(batchRequestContent);

List<Event> events = [];
foreach (var r in eventRequests)
{
    var response = await returnedResponse
      .GetResponseByIdAsync<EventCollectionResponse>(r);

    var pageIterator = PageIterator<Event, EventCollectionResponse>
   .CreatePageIterator(graphClient, response, (evt) =>
   {
       events.Add(new Event(evt));
       return true;
   });

    await pageIterator.IterateAsync();
}


return events;

SDK Version

5.58

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_
@PatrickKelley2112 PatrickKelley2112 added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Sep 25, 2024
@shemogumbe shemogumbe removed the status:waiting-for-triage An issue that is yet to be reviewed or assigned label Sep 25, 2024
@andrueastman
Copy link
Member

Thanks for raising this @PatrickKelley2112

Any chance you are able to share the details of the 400 response message you receive?

I believe the code below should throw an error/exception if the response is 400 that could be handled as shown in the doc
https://github.com/microsoftgraph/msgraph-sdk-dotnet/blob/main/docs/errors.md

    var response = await returnedResponse
      .GetResponseByIdAsync<EventCollectionResponse>(r);

@andrueastman andrueastman added the status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close label Sep 26, 2024
@PatrickKelley2112
Copy link
Author

It's not throwing an exception. I can only see what's happening by running returnedResponse.GetResponsesStatusCodesAsync(), and that only shows me that it's returning error 400 but no information about why.

Is there a way to see the data that is sent using graphClient.Batch.PostAsync(batchRequestContent)? If so, I can compare that data between the local client and the Azure app service.

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close Status: No recent activity labels Sep 30, 2024
@andrueastman
Copy link
Member

@PatrickKelley2112

I believe you can read the response content for the individual reponse as below

            HttpResponseMessage response = await returnedResponse.GetResponseByIdAsync("2");

            var responseBodyString = await response.Content.ReadAsStringAsync(); 

Also, could you add a reference to https://www.nuget.org/packages/Microsoft.Graph.Core/3.1.22 as well to validate this was not resolved via microsoftgraph/msgraph-sdk-dotnet-core#916

@andrueastman andrueastman added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed Needs: Attention 👋 labels Oct 1, 2024
Copy link
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: No recent activity status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close type:bug A broken experience
Projects
None yet
Development

No branches or pull requests

3 participants