MIME Content returns empty JSON or a 405 status using HTTP GET
Following the documentation, there are two ways suggested to acccess the content of a message via the Id:
1) GET /users/{id | userPrincipalName}/messages/{id}
2) GET /users/{id | userPrincipalName}/mailFolders/{id}/messages/{id}
Within the PHP SDK, I can obtain details of the message with the given Id perfectly fine, however, when adding /$value to obtain the MIME contents, the 1st URL returns an empty JSON where as the second URL returns a 405 Status with a custom message of The OData request is not supported.
Code to reproduce (405 Status - Also, replacing inbox with the Id of the mailFolder also returns 405):
return $graphSdk->createRequest('GET', sprintf('/users/%s/mailFolders/inbox/messages/%s/$value', '[email protected]', 'MESSAGE-ID-HERE'))
->setReturnType(MimeContent::class)
->execute();
Code to reproduce (empty JSON):
return $graphSdk->createRequest('GET', sprintf('/users/%s/messages/%s/$value', '[email protected]', 'MESSAGE-ID-HERE'))
->setReturnType(MimeContent::class)
->execute();
Removing $value and changing the return type to Message yeilds the intended Message instance as expected. The documentation does not give any guidence on this issue and seems like an API issue as appose to an SDK issue. This can also be reproduced on the Graph Explorer when using the Authorisation header.
Edit: When using delgate flow (oAuth 2.0) the signed in mailbox works fine with the above examples, when using application flow, I am presented with the above issues - this is not suggested in the documentation only by a hint in example 4 that potentially this only works against the "signed in users mailbox". In delegate flow, it doesn't however work if you're acting on behalf of a shared mailbox that the authenticated user has permission to access.