Skip to content

buildin_endpoints_get_workspace_path

Marcel Kloubert edited this page Feb 9, 2017 · 6 revisions

Home >> Build-in endpoints >> [GET] /api/workspace(/{path})

[GET] /api/workspace(/{path})

Lists a directory or returns the content of a file inside the workspace.

Examples

List root directory

Request:

GET /api/workspace

Possible response:

Content-type: application/json; charset=utf-8
X-vscode-restapi-type: directory
Content-encoding: gzip
X-Vscode-Restapi: 1.0.0
Date: Thu, 09 Feb 2017 20:55:25 GMT
Connection: keep-alive
Transfer-Encoding: chunked

{
    "code": 0,
    "data": {
        "dirs": [
            {
                "creationTime": "2017-01-22T14:26:56.482Z",
                "lastChangeTime": "2017-01-22T14:27:26.147Z",
                "lastModifiedTime": "2017-01-22T14:26:56.488Z",
                "name": "css",
                "path": "/api/workspace/css",
                "type": "dir"
            },
            {
                "creationTime": "2017-01-22T14:26:56.888Z",
                "lastChangeTime": "2017-01-22T14:27:26.152Z",
                "lastModifiedTime": "2017-01-22T14:26:56.908Z",
                "name": "js",
                "path": "/api/workspace/js",
                "type": "dir"
            },
            {
                "creationTime": "2017-01-22T14:26:26.631Z",
                "lastChangeTime": "2017-01-22T14:26:27.005Z",
                "lastModifiedTime": "2017-01-22T14:26:26.669Z",
                "name": "_res",
                "path": "/api/workspace/_res",
                "type": "dir"
            }
        ],
        "files": [
            {
                "creationTime": "2017-01-22T14:27:47.902Z",
                "lastChangeTime": "2017-01-23T21:07:37.595Z",
                "lastModifiedTime": "2017-01-23T21:07:37.595Z",
                "mime": "application/octet-stream",
                "name": "index.php",
                "path": "/api/workspace/index.php",
                "type": "file"
            },
            {
                "creationTime": "2017-02-01T23:58:54.173Z",
                "lastChangeTime": "2017-02-04T20:17:12.811Z",
                "lastModifiedTime": "2017-02-04T20:17:12.811Z",
                "mime": "text/html",
                "name": "test.html",
                "path": "/api/workspace/test.html",
                "type": "file"
            }
        ]
    }
}

List root directory

Request:

GET /api/workspace/myResources

Possible response:

Content-type: application/json; charset=utf-8
X-vscode-restapi-type: directory
Content-encoding: gzip
X-Vscode-Restapi: 1.0.0
Date: Thu, 09 Feb 2017 21:02:04 GMT
Connection: keep-alive
Transfer-Encoding: chunked

{
    "code": 0,
    "data": {
        "dirs": [
        ],
        "files": [
            {
                "creationTime": "2017-02-03T17:54:37.284Z",
                "lastChangeTime": "2017-02-03T20:52:14.480Z",
                "lastModifiedTime": "2017-02-03T20:52:14.480Z",
                "mime": "text/css",
                "name": "test.css",
                "path": "/api/workspace/myResources/test.css",
                "size": 15,
                "type": "file",
                "openPath": "/api/editor/myResources/test.css"
            },
            {
                "creationTime": "2017-02-03T17:54:40.630Z",
                "lastChangeTime": "2017-02-03T20:52:22.426Z",
                "lastModifiedTime": "2017-02-03T20:52:22.426Z",
                "mime": "application/javascript",
                "name": "test.js",
                "path": "/api/workspace/myResources/test.js",
                "size": 25,
                "type": "file",
                "openPath": "/api/editor/myResources/test.js"
            }
        ],
        "parent": "/api/workspace"
    }
}

Get file content

Request:

GET /api/workspace/test.html

Possible response:

Content-type: text/html
X-vscode-restapi-type: file
X-Vscode-Restapi: 1.0.0
Date: Thu, 09 Feb 2017 20:58:38 GMT
Connection: keep-alive
Transfer-Encoding: chunked

<html>
Hello, guys!
</html>

Other responses:

Code Description
404 Item does not exist.
Clone this wiki locally