Hi,
You cannot use the API if your mailbox is not on Exchange Online. Can you confirm if the mailbox is on-premises or on Exchange Online?
If you want to search something in a user's mailbox, you can use mailbox search:
New-ComplianceSearch: how to use the newer version of Search-Mailbox
Please Note: Since the web site is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.
If an Answer is helpful, please click "Accept Answer" and upvote it.
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.