MS graph api batch response parsing

Ullas ML 1 Reputation point
2022-12-15T21:20:55.637+00:00
   const response = await graphClient.api('/$batch').post(content);  
   const batchResponse = new BatchResponseContent(response);  

batchResponse.getResponses() is empty where as batchResponse.getResponseById() is not. any ideas whats happening here

We are invoking a batch request to fetch users like illustrated above. We do receive the response correctly but seeing issues parsing them. Please see attached sample response that we received

   {  
     "responses": [  
       {  
         "id": "0",  
         "status": 200,  
         "headers": {  
           "Cache-Control": "no-cache",  
           "x-ms-resource-unit": "2",  
           "OData-Version": "4.0",  
           "Content-Type": "application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8"  
         },  
         "body": {  
           "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users",  
           "value": [  
             {  
               "businessPhones": [  
                   
               ],  
               "displayName": "xxxxx",  
               "givenName": "xxxx",  
               "jobTitle": null,  
               "mail": "xxxxxxxxx",  
               "mobilePhone": null,  
               "officeLocation": null,  
               "preferredLanguage": "en-US",  
               "surname": "xxxx",  
               "userPrincipalName": "xxxxxxx",  
               "id": "xxxxxxx"  
             }  
           ]  
         }  
       }  
     ]  
   }  


 
Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.