[ad_1]
I am using Microsoft graph API to create/update/delete rows in Excel files
So most of the time my API will have to do operation with large excel files. So as document say we have to use workbook-session-id for better performance i tried using the same and the performance is as expected.
But as per the document below it also says that “Sometime to get the session id it may take indeterminate to complete Microsoft Graph also provides a long running operations pattern”
https://docs.microsoft.com/en-us/graph/api/workbook-createsession?view=graph-rest-1.0&tabs=http
But when i try to use the same i get following error:
- Below call gave me expected response header
request :
POST https://graph.microsoft.com/v1.0/me/drive/items/{drive-item-id}/workbook/worksheets({id})/createSession
Prefer: respond-async
Content-type: application/json
{
“persistChanges”: true
}
response:
HTTP/1.1 202 Accepted
Location: https://graph.microsoft.com/v1.0/me/drive/items/{drive-item-id}/workbook/operations/{operation-id}
- As recommended I made a polling request every 30 seconds to the url i got in location header from step1
I tried to do this many times and i never got success response, below is the sequence of error i get when i poll the request every 30 sec
Initially for few minutes i get status failed:
{“@odata.context”:”https://graph.microsoft.com/v1.0/$metadata#users(‘5cfd4699-1356-45c6-ab63-8c804020285c’)/drive/root/workbook/operations/$entity”,”id”:”8a780746-6142-4282-8af0-ffa26985fd98″,”status”:”failed”,”error”:{“code”:”serviceUnavailable”,”message”:”The service is not available. Please try your request again.”,”innerError”:{“code”:”transientFailure”,”message”:”The request failed
due to a transient error. Please try your request again after the cooldown duration specified by Retry-After header.”,”innerError”:{“code”:”CoauthSessionTerminated”,”message”:”The workbook needs to be updated. Click OK to continue.”}}}}
After sometime for i get status as running:
{“@odata.context”:”https://graph.microsoft.com/v1.0/$metadata#users(‘5cfd4699-1356-45c6-ab63-8c804020285c’)/drive/root/workbook/operations/$entity”,”id”:”8a780746-6142-4282-8af0-ffa26985fd98″,”status”:”running”}
{“@odata.context”:”https://graph.microsoft.com/v1.0/$metadata#users(‘5cfd4699-1356-45c6-ab63-8c804020285c’)/drive/root/workbook/operations/$entity”,”id”:”8a780746-6142-4282-8af0-ffa26985fd98″,”status”:”running”}
After sometime i get error “LostDepartedOperation”
{“error”:{“code”:”LostDepartedOperation”,”message”:”We’re sorry. We ran into a problem completing your request.”,”innerError”:{“code”:”notFoundUncategorized”,”message”:”The requested resource cannot be found.”,”innerError”:{“code”:”LostDepartedOperation”,”message”:”We’re sorry. We ran into a problem completing your request.”},”date”:”2022-06-02T09:14:58″,”request-id”:”43e48788-f225-45b3-97e1-a8ba1950ee53″,”client-request-id”:”43e48788-f225-45b3-97e1-a8ba1950ee53″}}}
PS C:\Users\AVVM4J744\Desktop\testingapp>
I never got a status as “succeeded” as expected 🙁
Below are my queries:
- Is my above implementation correct or am i doing something wrong ?
- When and how should i decide to use “long-running operation pattern” programmatically
Thanks
[ad_2]