Search code examples
angularazuremicrosoft-graph-apihttpclient

How to resolve InvalidRequest for batch graph APIs request


I am getting an error while combining requests in one HTTP call for Graph APIs. I had followed the official document from Here

this is the error I am getting,

enter image description here

Steps:

  1. Loading all Microsoft team chats for logged-in user
  2. Iterate 20 request and call batch APIs
  3. Getting "InvalidRequest" error

What is the possible way to resolve this issue?

Please provide suggestions.


Solution

  • One of the workaround you may follow : Based on the given MS DOC we have tried with microsoft graph api and tested successfully.

    We have tried the given MS DOC example with below request body ;

    {
        "requests": [
            {
                "id": "1",
                "method": "GET",
                "url": "/me/drive/root:/{file}:/content"
            },
            {
                "id": "2",
                "method": "GET",
                "url": "/me/planner/tasks"
            },
            {
                "id": "3",
                "method": "GET",
                "url": "/groups/{id}/events"
            },
            {
                "id": "4",
                "url": "/me",
                "method": "PATCH",
                "body": {
                    "city": "Redmond"
                },
                
                "headers": {
                    "Content-Type": "application/json"
                }
            }
        ]
    }
    

    In request header we have added the key value and run the query as below:

    enter image description here

    NOTE:- Make sure that you have formatted correctly in your request body while making an API call.

    For more information please refer the below links:-