How can i avoid getting a WAC Access Token error while triying to read a Excel File with Graph API?

Felix Read 30 Reputation points
2024-04-11T02:53:48.9933333+00:00

I created a piece of code in java that crawls a sharepoint site and reads the files in the site and depending on information of the file it will fill the values of some custom columns on the site and post the changes.

I do this by using the GraphApi to get the drive by the site and then recursively reading and iterating through the files. It seems to work for about 90% of the files.

But i am getting problems with SOME excel files, where i get a
SEVERE: Throwable detail: com.microsoft.graph.http.GraphServiceException: Error code: AccessDenied

Error message: Could not obtain a WAC access token.

I am logging in using a client and secret id for a app with all permissions.

I need to be able to read and tag these files, but i have no clue what i am doing wrong

Microsoft 365 and Office | SharePoint | For business | Windows
Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

5 answers

Sort by: Most helpful
  1. RaytheonXie_MSFT 40,476 Reputation points Microsoft External Staff
    2024-04-11T06:49:39.81+00:00

    Hi @Felix Read,

    Since our forum focus on c#, I am not familar with java. After doing some research, I found a similar issue with yours, please make a reference

    https://stackoverflow.com/questions/56576652/getting-wac-access-token-error-when-calling-microsoft-graph-api


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Felix Read 30 Reputation points
    2024-04-11T12:21:54.08+00:00

    Ah sorry i did not know this was focused only on C#.

    I saw that post and no this did not fix it, my issue get more complicated because as stated it works for 90% of the files, only a small group of excel files seems to give me the error.

    I will try to move my question to some other forum thank you

    0 comments No comments

  3. Felix Read 30 Reputation points
    2024-04-11T20:19:26.0933333+00:00

    I review the code, and if i keep it out of java i get the same WAC token error.

    But only when y try to access the workbook from the drive item.
    If i only work with the drive item i have access to it but when i try to access the workbook i get a error

    example this request :
    GET https://graph.microsoft.com/v1.0/drives/b!jn6JlS9atkeM-KROA_T53TioJ9238OZLp2jmjTjLFfKXNoWAwIdzTpnXR6T0ZTsa/items/01THFQ36VJGBJMBQET4ZM234CASRKTDA4M/workbook

    i get

    Error code: AccessDenied

    Error message: Could not obtain a WAC access token.

    0 comments No comments

  4. Felix Read 30 Reputation points
    2024-04-13T13:21:48.5566667+00:00

    I found out that my error was because of the excel version of the files.

    The Workbook call only works on xlsx files, not on xls

    0 comments No comments

  5. RaytheonXie_MSFT 40,476 Reputation points Microsoft External Staff
    2024-04-15T02:27:00.9966667+00:00

    Hi @Felix Read,

    I'm glad to hear you solve the problem ,if you have any issue about SharePoint, you are welcome to raise a ticket in this forum.

    By the way, since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others." and according to the scenario introduced here: Answering your own questions on Microsoft Q&A, I would make a brief summary of this thread:

    [How can i avoid getting a WAC Access Token error while triying to read a Excel File with Graph API?]

    Issue Symptom:

    Getting a WAC Access Token error while triying to read a Excel File with Graph API

    Solution:

    The error was because of the excel version of the files. The graph api only works for .xlsx files, .xls files doesn't support currently.


    You could click the "Accept Answer" button for this summary to close this thread, and this can make it easier for other community member's to see the useful information when reading this thread. Thanks for your understanding!

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.