createRequest returns array instead of classHow to obtain a directory extension in Azure AD using MS GraphGet a guest user by userPrincipalName with Microsoft GraphDriveItem.CreatedBy.Device property is null for files in OneDriveGet extension property values of the user of azure adThumbnail object has url, but no contenthow do you check out and check in ListItems?Office 365 Multi Geo - Issue with fetching PreferredDataLocation property for a user from Azure Active DirectoryFinding and Displaying Extension Properties in MS Graphms graph php sdk message object fails to check if there are attachmentsModelUser not found

What are "full piece" and "half piece" in chess?

What is the German word or phrase for "village returning to forest"?

Why isn't aluminium involved in biological processes?

Adjusting vertical spacing in fractions?

How to delete certain lists from a nested list?

Alternator dying so junk car?

License validity of unreleased project

When to ask for constructive criticism?

Why are road bikes (not time trial bikes) used in many triathlons?

Creating a character, is Noble a class or a background?

A scene of Jimmy diversity

Can a dragon's breath weapon pass through Leomund's Tiny Hut?

What advantages do focused Arrows of Slaying have over more generic ones?

Can you perfectly wrap a cube with this blocky shape?

How to remove the first colon ':' from a timestamp?

Is this artwork (used in a video game) real?

When did the US colonies/states stop making their own currencies?

Animal Shelter Management C++

(Piano) is the purpose of sheet music to be played along to? Or a guide for learning and reference during playing?

Why don't commercial aircraft adopt a slightly more seaplane-like design to allow safer ditching in case of emergency?

FPGA CPU's, how to find the max speed?

How fast does a character need to move to be effectively invisible?

Investing 30k Euro as a student with basic financial knowledge but lack of time

Why do so many pure math PhD students drop out or leave academia, compared to applied mathematics PhDs?



createRequest returns array instead of class


How to obtain a directory extension in Azure AD using MS GraphGet a guest user by userPrincipalName with Microsoft GraphDriveItem.CreatedBy.Device property is null for files in OneDriveGet extension property values of the user of azure adThumbnail object has url, but no contenthow do you check out and check in ListItems?Office 365 Multi Geo - Issue with fetching PreferredDataLocation property for a user from Azure Active DirectoryFinding and Displaying Extension Properties in MS Graphms graph php sdk message object fails to check if there are attachmentsModelUser not found






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








-1















I am trying to retrieve information on users using the Microsoft Graph Library for PHP.



But this code runs into the error Trying to get property 'getGivenName' of non-object.



$user = $graph->createRequest("GET", "/users")
->setReturnType(ModelUser::class)
->execute();


This is due to the fact, that $user is an array instead of an object!? What is wrong with the SDK (or my code)?



Is there any better documentation for the SDK???










share|improve this question






























    -1















    I am trying to retrieve information on users using the Microsoft Graph Library for PHP.



    But this code runs into the error Trying to get property 'getGivenName' of non-object.



    $user = $graph->createRequest("GET", "/users")
    ->setReturnType(ModelUser::class)
    ->execute();


    This is due to the fact, that $user is an array instead of an object!? What is wrong with the SDK (or my code)?



    Is there any better documentation for the SDK???










    share|improve this question


























      -1












      -1








      -1








      I am trying to retrieve information on users using the Microsoft Graph Library for PHP.



      But this code runs into the error Trying to get property 'getGivenName' of non-object.



      $user = $graph->createRequest("GET", "/users")
      ->setReturnType(ModelUser::class)
      ->execute();


      This is due to the fact, that $user is an array instead of an object!? What is wrong with the SDK (or my code)?



      Is there any better documentation for the SDK???










      share|improve this question
















      I am trying to retrieve information on users using the Microsoft Graph Library for PHP.



      But this code runs into the error Trying to get property 'getGivenName' of non-object.



      $user = $graph->createRequest("GET", "/users")
      ->setReturnType(ModelUser::class)
      ->execute();


      This is due to the fact, that $user is an array instead of an object!? What is wrong with the SDK (or my code)?



      Is there any better documentation for the SDK???







      microsoft-graph microsoft-graph-sdks






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 26 at 8:34







      Odido

















      asked Mar 26 at 8:14









      OdidoOdido

      52 bronze badges




      52 bronze badges






















          1 Answer
          1






          active

          oldest

          votes


















          0















          This is due to the fact, that $user is an array instead of an object!?




          That's right, since the endpoint GET Users returns the list of users, in the provided example:



           $users = $graph->createRequest("GET", "/users")
          ->setReturnType(MicrosoftGraphModelUser::class)
          ->execute();


          $users contains an array of objects of MicrosoftGraphModelUser type, and



           $givenName = $users[0]->getGivenName(); 


          gives GivenName property of first item in array.



          A specific user could be requested via GET /users/ userPrincipalName endpoint:



           $user = $graph->createRequest("GET", "/users/$userId")
          ->setReturnType(MicrosoftGraphModelUser::class)
          ->execute();


          In that case $user object is of MicrosoftGraphModelUser type:



           $givenName = $user->getGivenName();


          Update



          setReturnType function accept Microsoft Graph API entity type name, in your example it appears ModelUser points to type which doesn't belong to MicrosoftGraphModel namespace and as a result JSON response is not getting deserialized into class instance.



          Instead of



          setReturnType(ModelUser::class)


          try to specify fully qualified class name:



          setReturnType(MicrosoftGraphModelUser::class)





          share|improve this answer

























          • I've already tried this: ``` $user = $graph->createRequest("GET", "/users/owagner@ad-libitum.info") ->setReturnType(ModelUser::class) ->execute(); ``` This does not deliver an arry but an object - as intended. But I get the error Undefined property: MicrosoftGraphModelUser::$getGivenName when executing $givenName = $user->getGivenName();.

            – Odido
            Mar 26 at 16:07











          • @Odido, the answer has been updated

            – Vadim Gremyachev
            Mar 26 at 16:51











          • sorry, still the same error: Undefined property: MicrosoftGraphModelUser::$getGivenName

            – Odido
            Mar 27 at 7:07











          • By the way: the debugger says, my $user=MicrosoftGraphModeluser and in the user.php there is public function getGivenName().

            – Odido
            Mar 27 at 12:01










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55352518%2fcreaterequest-returns-array-instead-of-class%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0















          This is due to the fact, that $user is an array instead of an object!?




          That's right, since the endpoint GET Users returns the list of users, in the provided example:



           $users = $graph->createRequest("GET", "/users")
          ->setReturnType(MicrosoftGraphModelUser::class)
          ->execute();


          $users contains an array of objects of MicrosoftGraphModelUser type, and



           $givenName = $users[0]->getGivenName(); 


          gives GivenName property of first item in array.



          A specific user could be requested via GET /users/ userPrincipalName endpoint:



           $user = $graph->createRequest("GET", "/users/$userId")
          ->setReturnType(MicrosoftGraphModelUser::class)
          ->execute();


          In that case $user object is of MicrosoftGraphModelUser type:



           $givenName = $user->getGivenName();


          Update



          setReturnType function accept Microsoft Graph API entity type name, in your example it appears ModelUser points to type which doesn't belong to MicrosoftGraphModel namespace and as a result JSON response is not getting deserialized into class instance.



          Instead of



          setReturnType(ModelUser::class)


          try to specify fully qualified class name:



          setReturnType(MicrosoftGraphModelUser::class)





          share|improve this answer

























          • I've already tried this: ``` $user = $graph->createRequest("GET", "/users/owagner@ad-libitum.info") ->setReturnType(ModelUser::class) ->execute(); ``` This does not deliver an arry but an object - as intended. But I get the error Undefined property: MicrosoftGraphModelUser::$getGivenName when executing $givenName = $user->getGivenName();.

            – Odido
            Mar 26 at 16:07











          • @Odido, the answer has been updated

            – Vadim Gremyachev
            Mar 26 at 16:51











          • sorry, still the same error: Undefined property: MicrosoftGraphModelUser::$getGivenName

            – Odido
            Mar 27 at 7:07











          • By the way: the debugger says, my $user=MicrosoftGraphModeluser and in the user.php there is public function getGivenName().

            – Odido
            Mar 27 at 12:01















          0















          This is due to the fact, that $user is an array instead of an object!?




          That's right, since the endpoint GET Users returns the list of users, in the provided example:



           $users = $graph->createRequest("GET", "/users")
          ->setReturnType(MicrosoftGraphModelUser::class)
          ->execute();


          $users contains an array of objects of MicrosoftGraphModelUser type, and



           $givenName = $users[0]->getGivenName(); 


          gives GivenName property of first item in array.



          A specific user could be requested via GET /users/ userPrincipalName endpoint:



           $user = $graph->createRequest("GET", "/users/$userId")
          ->setReturnType(MicrosoftGraphModelUser::class)
          ->execute();


          In that case $user object is of MicrosoftGraphModelUser type:



           $givenName = $user->getGivenName();


          Update



          setReturnType function accept Microsoft Graph API entity type name, in your example it appears ModelUser points to type which doesn't belong to MicrosoftGraphModel namespace and as a result JSON response is not getting deserialized into class instance.



          Instead of



          setReturnType(ModelUser::class)


          try to specify fully qualified class name:



          setReturnType(MicrosoftGraphModelUser::class)





          share|improve this answer

























          • I've already tried this: ``` $user = $graph->createRequest("GET", "/users/owagner@ad-libitum.info") ->setReturnType(ModelUser::class) ->execute(); ``` This does not deliver an arry but an object - as intended. But I get the error Undefined property: MicrosoftGraphModelUser::$getGivenName when executing $givenName = $user->getGivenName();.

            – Odido
            Mar 26 at 16:07











          • @Odido, the answer has been updated

            – Vadim Gremyachev
            Mar 26 at 16:51











          • sorry, still the same error: Undefined property: MicrosoftGraphModelUser::$getGivenName

            – Odido
            Mar 27 at 7:07











          • By the way: the debugger says, my $user=MicrosoftGraphModeluser and in the user.php there is public function getGivenName().

            – Odido
            Mar 27 at 12:01













          0












          0








          0








          This is due to the fact, that $user is an array instead of an object!?




          That's right, since the endpoint GET Users returns the list of users, in the provided example:



           $users = $graph->createRequest("GET", "/users")
          ->setReturnType(MicrosoftGraphModelUser::class)
          ->execute();


          $users contains an array of objects of MicrosoftGraphModelUser type, and



           $givenName = $users[0]->getGivenName(); 


          gives GivenName property of first item in array.



          A specific user could be requested via GET /users/ userPrincipalName endpoint:



           $user = $graph->createRequest("GET", "/users/$userId")
          ->setReturnType(MicrosoftGraphModelUser::class)
          ->execute();


          In that case $user object is of MicrosoftGraphModelUser type:



           $givenName = $user->getGivenName();


          Update



          setReturnType function accept Microsoft Graph API entity type name, in your example it appears ModelUser points to type which doesn't belong to MicrosoftGraphModel namespace and as a result JSON response is not getting deserialized into class instance.



          Instead of



          setReturnType(ModelUser::class)


          try to specify fully qualified class name:



          setReturnType(MicrosoftGraphModelUser::class)





          share|improve this answer
















          This is due to the fact, that $user is an array instead of an object!?




          That's right, since the endpoint GET Users returns the list of users, in the provided example:



           $users = $graph->createRequest("GET", "/users")
          ->setReturnType(MicrosoftGraphModelUser::class)
          ->execute();


          $users contains an array of objects of MicrosoftGraphModelUser type, and



           $givenName = $users[0]->getGivenName(); 


          gives GivenName property of first item in array.



          A specific user could be requested via GET /users/ userPrincipalName endpoint:



           $user = $graph->createRequest("GET", "/users/$userId")
          ->setReturnType(MicrosoftGraphModelUser::class)
          ->execute();


          In that case $user object is of MicrosoftGraphModelUser type:



           $givenName = $user->getGivenName();


          Update



          setReturnType function accept Microsoft Graph API entity type name, in your example it appears ModelUser points to type which doesn't belong to MicrosoftGraphModel namespace and as a result JSON response is not getting deserialized into class instance.



          Instead of



          setReturnType(ModelUser::class)


          try to specify fully qualified class name:



          setReturnType(MicrosoftGraphModelUser::class)






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 26 at 16:50

























          answered Mar 26 at 15:28









          Vadim GremyachevVadim Gremyachev

          39.9k8 gold badges79 silver badges122 bronze badges




          39.9k8 gold badges79 silver badges122 bronze badges












          • I've already tried this: ``` $user = $graph->createRequest("GET", "/users/owagner@ad-libitum.info") ->setReturnType(ModelUser::class) ->execute(); ``` This does not deliver an arry but an object - as intended. But I get the error Undefined property: MicrosoftGraphModelUser::$getGivenName when executing $givenName = $user->getGivenName();.

            – Odido
            Mar 26 at 16:07











          • @Odido, the answer has been updated

            – Vadim Gremyachev
            Mar 26 at 16:51











          • sorry, still the same error: Undefined property: MicrosoftGraphModelUser::$getGivenName

            – Odido
            Mar 27 at 7:07











          • By the way: the debugger says, my $user=MicrosoftGraphModeluser and in the user.php there is public function getGivenName().

            – Odido
            Mar 27 at 12:01

















          • I've already tried this: ``` $user = $graph->createRequest("GET", "/users/owagner@ad-libitum.info") ->setReturnType(ModelUser::class) ->execute(); ``` This does not deliver an arry but an object - as intended. But I get the error Undefined property: MicrosoftGraphModelUser::$getGivenName when executing $givenName = $user->getGivenName();.

            – Odido
            Mar 26 at 16:07











          • @Odido, the answer has been updated

            – Vadim Gremyachev
            Mar 26 at 16:51











          • sorry, still the same error: Undefined property: MicrosoftGraphModelUser::$getGivenName

            – Odido
            Mar 27 at 7:07











          • By the way: the debugger says, my $user=MicrosoftGraphModeluser and in the user.php there is public function getGivenName().

            – Odido
            Mar 27 at 12:01
















          I've already tried this: ``` $user = $graph->createRequest("GET", "/users/owagner@ad-libitum.info") ->setReturnType(ModelUser::class) ->execute(); ``` This does not deliver an arry but an object - as intended. But I get the error Undefined property: MicrosoftGraphModelUser::$getGivenName when executing $givenName = $user->getGivenName();.

          – Odido
          Mar 26 at 16:07





          I've already tried this: ``` $user = $graph->createRequest("GET", "/users/owagner@ad-libitum.info") ->setReturnType(ModelUser::class) ->execute(); ``` This does not deliver an arry but an object - as intended. But I get the error Undefined property: MicrosoftGraphModelUser::$getGivenName when executing $givenName = $user->getGivenName();.

          – Odido
          Mar 26 at 16:07













          @Odido, the answer has been updated

          – Vadim Gremyachev
          Mar 26 at 16:51





          @Odido, the answer has been updated

          – Vadim Gremyachev
          Mar 26 at 16:51













          sorry, still the same error: Undefined property: MicrosoftGraphModelUser::$getGivenName

          – Odido
          Mar 27 at 7:07





          sorry, still the same error: Undefined property: MicrosoftGraphModelUser::$getGivenName

          – Odido
          Mar 27 at 7:07













          By the way: the debugger says, my $user=MicrosoftGraphModeluser and in the user.php there is public function getGivenName().

          – Odido
          Mar 27 at 12:01





          By the way: the debugger says, my $user=MicrosoftGraphModeluser and in the user.php there is public function getGivenName().

          – Odido
          Mar 27 at 12:01








          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55352518%2fcreaterequest-returns-array-instead-of-class%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript