问题
I'm currently implementing a sync queue service to sync a webapp's customers to Outlook's contacts.
I'm using the Graph API for the job. The creation and updating of contacts is done using graph's batch request.
There's a part in the docs about the response that I don't fully understand and pretty much ignored. I just want to make sure my implementation is correct.
In addition to the responses property, there might be a nextLink property in the batch response. This allows Microsoft Graph to return a batch response as soon as any of the individual requests has completed. To ensure that all individual responses have been received, continue to follow the nextLink as long as it exists.
I was wondering about the following:
when does
nextLink
show up? I've tried sending different requests but never received it. It's not really clear from the docs but my guess is that it appears when for some reason some of the requests in the batch did not complete in time?Would the pending requests show up as errors in the response or would they just be missing from it?
Will the
nextLink
be in form of@odata.nextLink
like in pagination requests? It does not specify that in the docs.How should I handle it when/if it does appear? Can I safely ignore it and just count on the next invocation of service (every 15mins) to retry and sync the pending requests?
回答1:
The paging mechanism mostly applies when you are querying Graph for data.
- The nextLink shows up if whatever query you had as part of one of your batch requests requires pagination (just as if you ran the request directly). For example this request as part of your batch job would cause one to appear, provided the targeted user has more than 10 folders:
{
"id":"1",
"method":"GET",
"url":"users/user@domain.tld/mailFolders"
}
- The response shows up as normal (with the first page of data included in the response body, along with the nextLink to get to the next page).
- Correct. In the above example, the nextLink shows up like this:
"@odata.nextLink":"https://graph.microsoft.com/beta/users/user@domain.tld/mailFolders?$skip=10
- You will need to follow the nextLink to get the rest of the data.
来源:https://stackoverflow.com/questions/53574745/microsoft-graph-batch-requests-nextlink