V2.4: getMessages and getChildFolders are empty
Pixolantis opened this issue · 2 comments
If I have a folder and want to read the subfolders or messages from it, the output is always empty. But if I count the contents, I get an output:
$mailFolderId = 'AA......=';
$mailFolders = $graphServiceClient->users()->byUserId($userId)->mailFolders()->byMailFolderId($mailFolderId)->get()->wait();
$checkFolderId = $mailFolders->getId(); // Result: Correct Id
echo 'Count child folder: '.$mailFolders->getChildFolderCount().'<br>'; // Result: 4
echo 'Count total items: '.$mailFolders->getTotalItemCount().'<br>'; // Result: 10
//$childFolders = $mailFolders->getChildFolders(); // Result: null
//$childFolders = $mailFolders->getMessages(); // Result: null
If I make a query for subfolders and messages with the folderId, it works and I also get the corresponding values:
$subMailFolders = $graphServiceClient->users()->byUserId($userId)->mailFolders()->byMailFolderId($mailFolderId)->childFolders()->get()->wait();
$messages = $graphServiceClient->users()->byUserId($userId)->mailFolders()->byMailFolderId($mailFolderId)->messages()->get()->wait();
Is this a bug or am I missing something?
Edit: The same with getAttachments()
Hi @Pixolantis ,
Looking at the API documentation, childFolders is a relationship which needs to be read separately by using the https://learn.microsoft.com/en-us/graph/api/mailfolder-list-childfolders?view=graph-rest-1.0&tabs=php#example-1-list-mail-folders
as in your working query.
See also https://learn.microsoft.com/en-us/graph/api/resources/mailfolder?view=graph-rest-1.0
Thank you. This is ok.
I was just a little confused by the two functions and therefore expected a corresponding output.