microsoftgraph / microsoftgraph/msgraph-sdk-php

MIME Content returns empty JSON or a 405 status using HTTP GET

Open
#1,210 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
669
Forks
150
Avg merge
15h 21m
Merged PRs (30d)
3

Description

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', 'example@example.com', 'MESSAGE-ID-HERE'))
    ->setReturnType(MimeContent::class)
    ->execute();

Code to reproduce (empty JSON):

return $graphSdk->createRequest('GET', sprintf('/users/%s/messages/%s/$value', 'example@example.com', '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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No repository files or tests are named. Start with the createRequest calls and MimeContent return type, then compare both message URL forms in Graph Explorer using delegated and application authorization, including shared mailboxes. Done means determining whether the behavior is an SDK defect or an API/authentication limitation and documenting or addressing the confirmed cause.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.