Skip to content

Requesting an empty collection returns an object of the return type #46

@vanpouckesven

Description

@vanpouckesven

When requesting a collection that returns an empty result the result is actually parsed to an object that was given in the ReturnType.

Example:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.plannerPlan)",
    "@odata.count": 0,
    "value": []
}

Results in

object(Microsoft\Graph\Model\PlannerPlan)[400]
  protected '_propDict' => 
    array (size=3)
      '@odata.context' => string 'https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.plannerPlan)' (length=82)
      '@odata.count' => int 0
      'value' => 
        array (size=0)
          empty

I think the system should handle this as an empty array. The problem can be found in the class \Microsoft\Graph\Http\GraphResponse - method getResponseAsObject - line 152 where the system checks if the variable '$values' is available. When given an empty array the system returns false and continues to parse the collection as an object, returning false results.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions