Forum Discussion

NeffDesign's avatar
NeffDesign
Copper Contributor
Apr 21, 2021

Microsoft Graph: JSON Batching & References

I need to make a request to https://docs.microsoft.com/en-us/graph/api/driveitem-list-children?view=graph-rest-1.0&tabs=http#http-request in OneDrive and then subsequently https://docs.microsoft.com/en-us/graph/api/driveitem-list-permissions?view=graph-rest-1.0&tabs=http#http-request 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 https://docs.microsoft.com/en-us/graph/json-batching#first-json-batch-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 https://docs.microsoft.com/en-us/graph/json-batching#sequencing-requests-with-the-dependson-property 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.

 

No RepliesBe the first to reply

Resources