Microsoft Graph: JSON Batching & References

Copper Contributor

I need to make a request to fetch the folder ID's in OneDrive and then subsequently fetch the permissions of those folders. I think I've determined there is not a single request to return all of this, but I was attempting to use batching in a single request.

The issue I can't solve is the ability to take the folder(s)' ID from the first GET and use it in the dependant/subsequent GETs.

 

Starting to believe it's not possible.

 

Request:

POST https://graph.microsoft.com/v1.0/$batch
Accept: application/json
Content-Type: application/json

 

Body:

{
    "requests": [
        {
            "id": "1",
            "method": "GET",
            "url": "/me/drive/items/{item-id}/children?$select=name,id"
        },
        {
            "id": "2",
            "dependsOn": ["2"],
            "method": "GET",
            "url": "/me/drive/items/{item-id: returned from ID-1}/permissions?$select=link"
        }
    ]
}

 

The first request in the batch returns an array of folder objects, each with the unique ID of the folder {item-id}.

 

I need to extract the IDs (1 to many) from the first response and reference them in the subsequent request to return the permissions of that folder/item.

 

Or if there is a way to return the permissions along with the folder/item details, but I have found this to not be possible.

 

If I can't do this as a "batch", my alternative is to make two calls: (1) get the folder(s) ID, (2) Process the data and make a separate call to return the permissions.

 

0 Replies