issue when trying to fetch resource I got from webhook

Artur Ter-Stepanyan 0 Reputation points
2025-04-23T12:54:22.2+00:00

Hi, sometimes when I try to fetch the resource (message) that I got from webhook, it returns
USER_ID - is an actual user ID I just do not want to put it publicly , so I've just hide it.
Error fetching message: Client error: `GET https://graph.microsoft.com/v1.0/Users/USER_ID/Messages/AAMkAGQwNzg2MjEzLWQ5N2YtNGIyNS1iZjZjLWEwNDQ3NTY2NTk1MgBGAAAAAADTrAL_ryowRZ0mP3qR1yXbBwBXyHD7-FpMR6r2LGBGwMR-AAAAAAEMAABXyHD7-FpMR6r2LGBGwMR-AAYeQKlTAAA=` resulted in a `404 Not Found` response: {"error":{"code":"ErrorItemNotFound","message":"The specified object was not found in the store., The process failed to (truncated...) )

sometimes the webhook resource url works , sometimes it returns ItemNotFound error
here is the way I fetch the email and how I create subscriptions

/ Subscription data
$subscriptionData = [
    'changeType' => 'created',
    'notificationUrl' => OUTLOOK_MESSAGES_SUBSCRIPTION_WEBHOOK_URL, // Your webhook URL
    'resource' => "/me/mailfolders('inbox')/messages",
    'expirationDateTime' => date('c', strtotime('+1 day')), // Maximum of 4230 minutes (under 72 hours)
    'clientState' => OUTLOOK_WEBHOOK_CLIENT_STATE // Optional, used to validate notifications
];

    $subscription = $this->graph->createRequest('POST', '/subscriptions')
        ->attachBody($subscriptionData)
        ->setReturnType(Model\Subscription::class)
        ->execute();
return $this->graph->createRequest("GET", $resourceUrl)
    ->setReturnType(Model\Message::class)
    ->execute();

is there anything I'm doing wrong?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,605 questions
0 comments No comments
{count} votes

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.