Rest Api Read Files in a Folder
Hi,
I would like to get the files and their id's in a given folder. On documentation page about api there is an example;
curl -u '<username>:<password>' -X GET 'http://<Datameer-serverIP>:<port-number>/api/filesystem/folders/<file-id> or <uuid>'
|
But here, I am supposed to give a file_id, which I could not understand why I need to give a file_id while I try to get the content of a folder. Is it possible to do that by folder path etc?
thanks
-
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
-
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.
-
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.
Please sign in to leave a comment.
Comments
5 comments