setReturnType(Model\User::class) ->execute(); How can I know the return type of /me call is Model\User::" /> setReturnType(Model\User::class) ->execute(); How can I know the return type of /me call is Model\User::" /> setReturnType(Model\User::class) ->execute(); How can I know the return type of /me call is Model\User::"/>

Which document describe the result class of every api call in microsoft graph php sdk?

249 Views Asked by At
$user = $graph->createRequest("GET", "/me")
                      ->setReturnType(Model\User::class)
                      ->execute();

How can I know the return type of /me call is Model\User::class?

1

There are 1 best solutions below

0
Vadim Gremyachev On BEST ANSWER

To determine endpoint entity type the following approach could be considered. Set Accept header to odata.metadata=full to return @odata.type property along with data in response payload(refer OData spec for a more details)

Example

$resp = $client->createRequest("GET", "/me")
    ->addHeaders(array(
        "Accept" => "application/json;odata.metadata=full;odata.streaming=true"
    ))
    ->execute();

$entity = $resp->getBody();
$entityType = $entity["@odata.type"];

Result

For the provide example $entityType returns #microsoft.graph.user which corresponds to Microsoft\Graph\Model\User type from msgraph-sdk-php