We are using the below Graph API request to list mail folders from a mailbox in a hybrid deployment tenant.
https://graph.microsoft.com/v1.0/users/mailid/MailFolders/?$top=500
We are seeing we are getting sometimes API HttpError with Status Code 400 and sometimes API HttpError with Status Code 404 for the same mailbox
API HttpError 400 when requesting https://graph.microsoft.com/v1.0/users/[mailid]/MailFolders/?$top=500
Response:{u'error': {u'innerError': {u'date': u'2023-05-26T07:41:43', u'request-id': u'xxxxxxxxxxxxxxxxx', u'client-request-id': u'xxxxxxxxxxxxxxxxxxxxxxxxxxxx'}, u'message': u'Error authenticating with resource', u'code': u'AuthenticationError'}}'
API HttpError 404 when requesting https://graph.microsoft.com/v1.0/users/[mailid]/MailFolders/?$top=500 _
Response:{u'error': {u'innerError': {u'date': u'2023-05-31T11:48:23', u'request-id': u'xxxxxxxxxxxx', u'client-request-id': u'xxxxxxxxxxxxxxxxx'}, u'message': u'The mailbox is either inactive, soft-deleted, or is hosted on-premise.', u'code': u'MailboxNotEnabledForRESTAPI'}}_
Can someone help why we are getting different responses every time? and what does API Status Code 400 and API Status Code 400 and 'message': u'Error authenticating with resource', u'code': u'AuthenticationError' signifies?