user activity api not working don't know why

Youssef Gabr 1 Reputation point
2022-11-22T15:51:22.57+00:00

Following the docs to Build Java apps with Microsoft Graph successfully and after that I wanted to add an api to Get user activities the api returns a success message

Nov 22, 2022 5:28:34 PM com.azure.core.util.logging.ClientLogger performDeferredLogging  
INFO: Azure Identity => getToken() result for scopes [user.read, mail.read, mail.send, UserActivity.ReadWrite.CreatedByApp]:SUCCESS  

then it freezes

for approx. 15-20 minutes then it returns this error

Nov 22, 2022 5:37:38 PM com.microsoft.graph.logger.DefaultLogger logError  
SEVERE: CoreHttpProvider[sendRequestInternal] - 409Graph service exception Error code: UnknownError  
Nov 22, 2022 5:37:38 PM com.microsoft.graph.logger.DefaultLogger logError  
SEVERE: CoreHttpProvider[sendRequestInternal] - 409Error message: {"Message":"Request limit exceeded for Authentication Failure"}  
Nov 22, 2022 5:37:38 PM com.microsoft.graph.logger.DefaultLogger logError  
SEVERE: CoreHttpProvider[sendRequestInternal] - 409  
Nov 22, 2022 5:37:38 PM com.microsoft.graph.logger.DefaultLogger logError  
SEVERE: CoreHttpProvider[sendRequestInternal] - 409GET https://graph.microsoft.com/v1.0/me/activities/microsoft.graph.recent?%24orderby=lastModifiedDateTime%20DESC  
Nov 22, 2022 5:37:38 PM com.microsoft.graph.logger.DefaultLogger logError  
SEVERE: CoreHttpProvider[sendRequestInternal] - 409SdkVersion : graph-java/v5.22.0  
Nov 22, 2022 5:37:38 PM com.microsoft.graph.logger.DefaultLogger logError  
SEVERE: CoreHttpProvider[sendRequestInternal] - 409  
Nov 22, 2022 5:37:38 PM com.microsoft.graph.logger.DefaultLogger logError  
SEVERE: CoreHttpProvider[sendRequestInternal] - 409  
Nov 22, 2022 5:37:38 PM com.microsoft.graph.logger.DefaultLogger logError  
SEVERE: CoreHttpProvider[sendRequestInternal] - 409429 :   
Nov 22, 2022 5:37:38 PM com.microsoft.graph.logger.DefaultLogger logError  
SEVERE: CoreHttpProvider[sendRequestInternal] - 409[...]  
Nov 22, 2022 5:37:38 PM com.microsoft.graph.logger.DefaultLogger logError  
SEVERE: CoreHttpProvider[sendRequestInternal] - 409  
Nov 22, 2022 5:37:38 PM com.microsoft.graph.logger.DefaultLogger logError  
SEVERE: CoreHttpProvider[sendRequestInternal] - 409[Some information was truncated for brevity, enable debug logging for more details]  
Nov 22, 2022 5:37:38 PM com.microsoft.graph.logger.DefaultLogger logError  
SEVERE: Throwable detail: com.microsoft.graph.http.GraphServiceException: Error code: UnknownError  
Error message: {"Message":"Request limit exceeded for Authentication Failure"}  
  
GET https://graph.microsoft.com/v1.0/me/activities/microsoft.graph.recent?%24orderby=lastModifiedDateTime%20DESC  
SdkVersion : graph-java/v5.22.0  
  
  
429 :   
[...]  
  
[Some information was truncated for brevity, enable debug logging for more details]  
com.microsoft.graph.http.GraphServiceException: Error code: UnknownError  
Error message: {"Message":"Request limit exceeded for Authentication Failure"}  
  
GET https://graph.microsoft.com/v1.0/me/activities/microsoft.graph.recent?%24orderby=lastModifiedDateTime%20DESC  
SdkVersion : graph-java/v5.22.0  
  
  
429 :   
[...]  
  
[Some information was truncated for brevity, enable debug logging for more details]  
com.microsoft.graph.http.GraphServiceException: Error code: UnknownError  
Error   

message: {"Message":"Request limit exceeded for Authentication Failure"}  

  
GET https://graph.microsoft.com/v1.0/me/activities/microsoft.graph.recent?%24orderby=lastModifiedDateTime%20DESC  
SdkVersion : graph-java/v5.22.0  
  
  
429 :   
[...]  
  
[Some information was truncated for brevity, enable debug logging for more details]  
	at com.microsoft.graph.http.GraphServiceException.createFromResponse(GraphServiceException.java:419)  
	at com.microsoft.graph.http.GraphServiceException.createFromResponse(GraphServiceException.java:378)  
	at com.microsoft.graph.http.CoreHttpProvider.handleErrorResponse(CoreHttpProvider.java:514)  
	at com.microsoft.graph.http.CoreHttpProvider.processResponse(CoreHttpProvider.java:443)  
	at com.microsoft.graph.http.CoreHttpProvider.sendRequestInternal(CoreHttpProvider.java:409)  
	at com.microsoft.graph.http.CoreHttpProvider.send(CoreHttpProvider.java:226)  
	at com.microsoft.graph.http.CoreHttpProvider.send(CoreHttpProvider.java:203)  
	at com.microsoft.graph.http.BaseCollectionRequest.send(BaseCollectionRequest.java:103)  
	at com.microsoft.graph.http.BaseFunctionCollectionRequest.get(BaseFunctionCollectionRequest.java:79)  
	at graphtutorial.Graph.userActivity(Graph.java:134)  
	at graphtutorial.App.listUserRecentActivities(App.java:211)  
	at graphtutorial.App.main(App.java:9)  

I think the this part Error message: {"Message":"Request limit exceeded for Authentication Failure"} of the error
is why I am getting the it I don't know why it is a authentication failure and yes I have read the docs and have given the permission in the docs.
This delegated permission is added to the app as per the docs UserActivity.ReadWrite.CreatedByApp
and the authorization token is constructed as the docs of the Build Java apps with Microsoft Graph

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,708 questions
{count} votes

1 answer

Sort by: Most helpful
  1. HarmeetSingh7172 4,811 Reputation points
    2022-11-23T03:55:38.743+00:00

    Hello @Youssef Gabr

    Thanks for reaching out.

    Please find my testing details below.

    Scenario 1: Without giving UserActivity.ReadWrite.CreatedByApp permission and using $orderBy query parameter - I'm able to reproduce the error message you are getting.

    263277-without-permission10.png

    Scenario 2: Post giving UserActivity.ReadWrite.CreatedByApp permission and using $orderBy query parameter - Results in Bad request, because $orderBy is not supported for this API. Refer this to check supported Query parameters.

    263278-using-orderby10.png

    Scenario 3: Post giving UserActivity.ReadWrite.CreatedByApp permission and using $filter parameter on lastModifiedDateTime property as documented here. - API is working as expected

    263285-usingfilter10.png

    References: https://learn.microsoft.com/en-us/graph/api/projectrome-get-recent-activities?view=graph-rest-1.0&tabs=http

    ----------

    Hope this helps.

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

    1 person found this answer helpful.