Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Unable to retrieve sub folders using getFolderContents #11

Open
hishamyounis opened this issue Aug 2, 2017 · 1 comment
Open

Unable to retrieve sub folders using getFolderContents #11

hishamyounis opened this issue Aug 2, 2017 · 1 comment
Assignees

Comments

@hishamyounis
Copy link

The folders API uses a JsonApicollection to represent the response type of the getFolderContents() function. This causes the response to only display the top level folders, but you cannot retrieve the sub folders. Here's an example response:

object(Autodesk\Forge\Client\Model\JsonApiCollection)[169]
  protected 'container' => 
    array (size=2)
      'jsonapi' => 
        object(Autodesk\Forge\Client\Model\JsonApiVersionJsonapi)[163]
          protected 'container' => 
            array (size=1)
              'version' => string '1.0' (length=3)
      'data' => 
        array (size=1)
          0 => 
            object(Autodesk\Forge\Client\Model\JsonApiResource)[164]
              protected 'container' => 
                array (size=6)
                  'id' => string 'urn:adsk.wipprod:fs.folder:co.jgh51Mz5RF6lU1Zxg0Q3ag' (length=52)
                  'type' => string 'folders' (length=7)
                  'attributes' => 
                    object(Autodesk\Forge\Client\Model\JsonApiAttributes)[165]
                      protected 'container' => 
                        array (size=0)
                          empty
                  'meta' => null
                  'relationships' => 
                    object(Autodesk\Forge\Client\Model\JsonApiRelationships)[162]
                      protected 'container' => 
                        array (size=0)
                          empty
                  'links' => 
                    object(Autodesk\Forge\Client\Model\JsonApiLinks)[144]
                      protected 'container' => 
                        array (size=0)
                          empty

I worked around this by changing FoldersAPI.php line #284 from:
$this->apiClient->getSerializer()->deserialize($response, '\Autodesk\Forge\Client\Model\JsonApiCollection', $httpHeader),
to:
$this->apiClient->getSerializer()->deserialize($response, 'object', $httpHeader),

Then I manually parsed the retrieved object to extract the subfolders information. Deserializing the response as an object, for the same request, produces the following output:

array (size=3)
  'jsonapi' => 
    object(stdClass)[183]
      public 'version' => string '1.0' (length=3)
  'links' => 
    object(stdClass)[191]
      public 'self' => 
        object(stdClass)[192]
          public 'href' => string 'https://developer.api.autodesk.com/data/v1/projects/b.3300e3a3-8e63-437d-b5e0-2c7366e7c625/folders/urn:adsk.wipprod:fs.folder:co.fzu-FNn9TtS91jpUvBl_OQ/contents' (length=160)
  'data' => 
    array (size=1)
      0 => 
        object(stdClass)[194]
          public 'type' => string 'folders' (length=7)
          public 'id' => string 'urn:adsk.wipprod:fs.folder:co.jgh51Mz5RF6lU1Zxg0Q3ag' (length=52)
          public 'attributes' => 
            object(stdClass)[193]
              public 'name' => string 'Notices and Waivers' (length=19)
              public 'displayName' => string 'Notices and Waivers' (length=19)
              public 'createTime' => string '2017-07-19T02:56:23.0000000Z' (length=28)
              public 'createUserId' => string 'LAPVJM28ZSQT' (length=12)
              public 'createUserName' => string 'UNKNOWN%20UNKNOWN' (length=17)
              public 'lastModifiedTime' => string '2017-07-19T17:49:59.0000000Z' (length=28)
              public 'lastModifiedUserId' => string '' (length=0)
              public 'lastModifiedUserName' => string '' (length=0)
              public 'objectCount' => int 13
              public 'hidden' => boolean false
              public 'extension' => 
                object(stdClass)[188]
                  public 'type' => string 'folders:autodesk.bim360:Folder' (length=30)
                  public 'version' => string '1.0' (length=3)
                  public 'schema' => 
                    object(stdClass)[189]
                      public 'href' => string 'https://developer.api.autodesk.com/schema/v1/versions/folders:autodesk.bim360:Folder-1.0' (length=88)
                  public 'data' => 
                    object(stdClass)[190]
                      public 'visibleTypes' => 
                        array (size=1)
                          0 => string 'items:autodesk.bim360:File' (length=26)
                      public 'actions' => 
                        array (size=1)
                          0 => string 'CONVERT' (length=7)
                      public 'allowedTypes' => 
                        array (size=2)
                          0 => string 'items:autodesk.bim360:File' (length=26)
                          1 => string 'folders:autodesk.bim360:Folder' (length=30)
          public 'links' => 
            object(stdClass)[184]
              public 'self' => 
                object(stdClass)[187]
                  public 'href' => string 'https://developer.api.autodesk.com/data/v1/projects/b.3300e3a3-8e63-437d-b5e0-2c7366e7c625/folders/urn:adsk.wipprod:fs.folder:co.jgh51Mz5RF6lU1Zxg0Q3ag' (length=151)
          public 'relationships' => 
            object(stdClass)[185]
              public 'contents' => 
                object(stdClass)[186]
                  public 'links' => 
                    object(stdClass)[179]
                      public 'related' => 
                        object(stdClass)[161]
                          public 'href' => string 'https://developer.api.autodesk.com/data/v1/projects/b.3300e3a3-8e63-437d-b5e0-2c7366e7c625/folders/urn:adsk.wipprod:fs.folder:co.jgh51Mz5RF6lU1Zxg0Q3ag/contents' (length=160)
              public 'parent' => 
                object(stdClass)[166]
                  public 'data' => 
                    object(stdClass)[174]
                      public 'type' => string 'folders' (length=7)
                      public 'id' => string 'urn:adsk.wipprod:fs.folder:co.fzu-FNn9TtS91jpUvBl_OQ' (length=52)
                  public 'links' => 
                    object(stdClass)[175]
                      public 'related' => 
                        object(stdClass)[177]
                          public 'href' => string 'https://developer.api.autodesk.com/data/v1/projects/b.3300e3a3-8e63-437d-b5e0-2c7366e7c625/folders/urn:adsk.wipprod:fs.folder:co.jgh51Mz5RF6lU1Zxg0Q3ag/parent' (length=158)
              public 'refs' => 
                object(stdClass)[176]
                  public 'links' => 
                    object(stdClass)[171]
                      public 'self' => 
                        object(stdClass)[172]
                          public 'href' => string 'https://developer.api.autodesk.com/data/v1/projects/b.3300e3a3-8e63-437d-b5e0-2c7366e7c625/folders/urn:adsk.wipprod:fs.folder:co.jgh51Mz5RF6lU1Zxg0Q3ag/relationships/refs' (length=170)
                      public 'related' => 
                        object(stdClass)[173]
                          public 'href' => string 'https://developer.api.autodesk.com/data/v1/projects/b.3300e3a3-8e63-437d-b5e0-2c7366e7c625/folders/urn:adsk.wipprod:fs.folder:co.jgh51Mz5RF6lU1Zxg0Q3ag/refs' (length=156)
              public 'links' => 
                object(stdClass)[167]
                  public 'links' => 
                    object(stdClass)[170]
                      public 'self' => 
                        object(stdClass)[168]
                          public 'href' => string 'https://developer.api.autodesk.com/data/v1/projects/b.3300e3a3-8e63-437d-b5e0-2c7366e7c625/folders/urn:adsk.wipprod:fs.folder:co.jgh51Mz5RF6lU1Zxg0Q3ag/relationships/links' (length=171)
@cdeguet
Copy link

cdeguet commented Dec 14, 2018

I have the same issue, still not fixed. Is this PHP API officially supported at all?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants