question

Sean2001-4704 avatar image
0 Votes"
Sean2001-4704 asked Deva-MSFT edited

GraphAPI - WorksheetProtection: Unprotect Function via Graph API throws CompactToken parsing error: 80049217

I'm getting an error (CompactToken parsing failed with error code: 80049217) when trying to call the "/protection/unprotect" method on an Excel Worksheet with GraphAPI in both Power Automate Flow & Graph Explorer for testing.

Power Automate Flow gets AccessToken via this method (which works fine): https://laurakokkarinen.com/calling-microsoft-graph-from-microsoft-flow-and-other-daemon-apps-with-delegated-permissions/

The URL I'm testing with looks like:
https://graph.microsoft.com/v1.0/me/drive/root:/test/MYtest.xlsx:/workbook/worksheets/{49875BA4-E169-44A6-8EC5-1374154E60AF}/protection/unprotect

Here are the exports of the POST & Response:

{"log":{"version":"4.0","creator":{"name":"Graph Explorer","version":"4.0"},"entries":[{"startedDateTime":"2021-04-22T12:22:00.650Z","time":160,"request":{"method":"POST","url":"https://graph.microsoft.com/v1.0/me/drive/root:/test/MyTest.xlsx:/workbook/worksheets/{49875BA4-E169-44A6-8EC5-1374154E60AF}/protection/unprotect","httpVersion":"HTTP/1.1","cookies":[],"headers":[{"name":"authorization","value":"Bearer eyJ0eXAiOiJ...........<Access Token is being pasted in from AccessToken on Graph Explorer UI ..............>"},{"name":"accept","value":"application/json"},{"name":"Content-type","value":"application/json"}],"queryString":[{"name":"","value":""}],"postData":{"mimeType":"application/json","text":{"password":"sheetPasswordIncludedHere"}},"headersSize":-1,"bodySize":-1},


"response":{"status":401,"statusText":"Unauthorized","httpVersion":"HTTP/1.1","cookies":[],"headers":{"client-request-id":"c9b966a6-0157-1263-904b-d897b9cafeda","content-type":"application/json","request-id":"1636c6ef-0b64-4409-8097-e6d4d5938994","www-authenticate":"Bearer realm=\"\", authorization_uri=\"https://login.microsoftonline.com/common/oauth2/authorize\", client_id=\"00000003-0000-0000-c000-000000000000\""},"content":{"text":"{\"error\":{\"code\":\"InvalidAuthenticationToken\",\"message\":\"CompactToken parsing failed with error code: 80049217\",\"innerError\":{\"date\":\"2021-04-22T12:22:00\",\"request-id\":\"1636c6ef-0b64-4409-8097-e6d4d5938994\",\"client-request-id\":\"c9b966a6-0157-1263-904b-d897b9cafeda\"}}}","size":268,"mimeType":"application/json"},"redirectURL":"","headersSize":-1,"bodySize":-1},"cache":{},"timings":{"send":0,"wait":0,"receive":0},"connection":""}]}}

Any help would be very much appreciated.

microsoft-graph-workbooks
· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Adding right tags/teams to assist

1 Vote 1 ·

CompactToken parsing failed with error code: 80049217 can be because you have not added the token the right way. Could you try this on Graph Explorer and attach the screenshot of the error that you get? It is unclear the source of the request you have attached. Also please format the JSON to be easily readable.

1 Vote 1 ·

@Sean2001-4704 Happy to help, I believe this one is another issue. Please open a new question for this one and let me know if the initial comment answers the initial question so that I can add it as the answer for you to accept and close this question.

1 Vote 1 ·

Thanks for the guidance Danstan. Yes, this can be closed to the comments, because the behavior seems different in Power Automate, but I figure easier to get help to get this working in Graph Explorer.

Please see this one and thank you very in advance for any assistance - I'm really stuck here with the API unprotect.
https://docs.microsoft.com/en-us/answers/questions/383620/graphapi-worksheetprotection-unprotect-function-fa.html

0 Votes 0 ·

Thanks for the reply Danstan.

So actually I was somewhat mistaken always getting the 80049217 error in PowerAutomate, when I add "Bearer " + AccessToken, I'm getting Invalid Argument error in Graph Explorer.
92939-bearer.jpg

If I can get Graph Explorer to work I'm thinking I can then look to see what is different, but not sure what I'm missing per the API documentation:

https://docs.microsoft.com/en-us/graph/api/worksheetprotection-unprotect?view=graph-rest-1.0&tabs=http

JSON Password in body of request:
92949-body.jpg

When I only add the token without the prefix "Bearer ", I'm getting the 80049217 error. So, maybe the token is fine in Graph Explorer, but I can't seem to figure out what I'm missing in the requests?

92889-nobearer.jpg

Thanks very much,


0 Votes 0 ·
bearer.jpg (265.6 KiB)
nobearer.jpg (236.8 KiB)
body.jpg (83.9 KiB)

0 Answers