Rest Api Read Files in a Folder

Comments

5 comments

  • Alan Mark

    Hi Tugrul,

    Each folder artifact is considered a file in of itself.

    If you use the root-folder API call you'll  get a response that includes the href value for each folder:

    curl -u '<username>:<password>' -X GET 'http://<Datameer-serverIP>:<port-number>/api/filesystem/root-folder'
    ... 
    { "name": "Data", "_links": { "self": { "href": "/api/filesystem/folders/4" } } },
    ...

    So here my Data folder has a file id of 4 as garnered from the href "/api/filesystem/folders/4".

    Now that you know the id is 4, this can then be used in the folder query as the <file-id>.  Just the 4, not the entire href.

    Let me know if that doesn't clarify it for you.

    Alan

     

    0
    Comment actions Permalink
  • Tugrul Bayrak

    Hi Alan,

    Thanks for your answer. I did not know that folders are represented by file_id's. Now I can reach to workbooks File ID's for a folder. Is there a way to retrieve ID of a workbook from here, since I need ID to read a workbook not File ID, thanks.

    Tuğrul

    0
    Comment actions Permalink
  • Alan Mark

    Hi Tugrul,

    When you get the ID of your folder, then list the contents using the folders API, the id of your workbooks is included in the href for each file like it is for the folders.

    So for example:

    curl -u '<username>:<password>' -X GET 'http://<Datameer-serverIP>:<port-number>/api/filesystem/root-folder'

    Run the above, and get the ID for the Analytics folder, then Workbooks folder:

          {
            "name": "Analytics",
            "_links": {
              "self": {
                "href": "/api/filesystem/folders/10"
              }
            }
          },
    curl -u '<username>:<password>' -X GET 'http://<Datameer-serverIP>:<port-number>/api/filesystem/folders/10'
    "folders": [
          {
            "name": "Workbooks",
            "_links": {
              "self": {
                "href": "/api/filesystem/folders/11"
              }
            }
          }

    List the contents of your Workbooks folder:

    curl -u '<username>:<password>' -X GET 'http://<Datameer-serverIP>:<port-number>/api/filesystem/folders/11'
          {
            "name": "Workbook_TEZ.wbk",
            "_links": {
              "self": {
                "href": "/api/filesystem/files/10"
              }
            }
          },

    Use the ID for the API for workbooks:

    curl -u '<username>:<password>' -X GET 'http://<Datameer-serverIP>:<port-number>/api/workbooks/10

    This should give you the full JSON description of the workbook itself.

    0
    Comment actions Permalink
  • Alan Mark

    Hi Tugrul,

    You'll note a slight difference in the command I demonstrated:

    curl -u '<username>:<password>' -X GET 'http://<Datameer-serverIP>:<port-number>/api/workbooks/10
    api/workbooks/FileID

    vs

    rest/workbooks/ID

    The difference here is our rest API version 1 vs version 2.  API 1 used the "Configuration ID" for calls, but API 2 now uses the File ID to make things easier to work with.

    0
    Comment actions Permalink
  • Tugrul Bayrak

    Now I can see what I have missed, thank you so much, cheers!

    0
    Comment actions Permalink

Please sign in to leave a comment.