Drive API Overview

    The LINE WORKS Drive API (hereinafter, the "Drive API") is a set of APIs that is required to upload and download files to and from LINE WORKS Drive, and retrieve files and group folders in it.

    Prerequisite

    The Drive API provides a unique URL for each client, using an "API ID." To use the Drive API, get an "API ID" from LINE WORKS and insert it in each API URL. However, you can make API requests to upload and download files without an "API ID."

    Getting an API ID

    An API ID is used in the Drive API's request URL. For how to get an API ID, see Preparations for API Authentication.

    OAuth 2.0 Authentication

    You need an authentication token and a consumer key for OAuth 2.0 authentication. For how to get a consumer key and server token, see Preparations for API Authentication.

    How to Use

    Add your authentication token and consumer key to the API request header as in the following code. Add the authentication token in "Authorization" in "Bearer" type, and the consumer key in "consumerKey."

    requestHeader.set("Authorization", "Bearer AAAA8…");
    requestHeader.set("consumerKey", "AbCdEfGhIjKlMn");
    

    Sample Code for Java

    String url = "https://apis.worksmobile.com/r/{API ID}/drive/rl/{resourceLocation}/v2/files/{resourceKey}";
    Map<String, String> urlVariables = new HashMap<>();
    urlVariables.put("API ID", "kr1xxxxx");
    urlVariables.put("resourceLocation", "24101");
    urlVariables.put("resourceKey", "jfjefo098f21xaff");
    
    RestTemplate restTemplate = new RestTemplate();
    HttpHeaders requestHeader = new HttpHeaders();
    requestHeader.setContentType(MediaType.APPLICATION_JSON);
    requestHeader.set("Authorization", "Bearer AAAA8…");
    requestHeader.set("consumerKey", "AbCdEfGhIjKlMn");
    
    HttpEntity<P> requestEntity = new HttpEntity<P>(params, requestHeader);
    ResponseEntity<T> responseBody = restTemplate.exchange(url, httpMethod, requestEntity, typeReference, urlVariables);
    

    API Common Information

    The Drive API is subdivided into two types, upload/download APIs and other APIs, and each type uses different server domains. For server domains, please refer to each API description.

    resourceLocation

    For resourceLocation, a required common path parameter, use the resourceLocation value of the resource to get.

    Note that you need to use the response after calling the Get Properties API of your ROOT folder (of which the resourceKey is root) if you want to get the resourceLocation of your files or folders.

    To get the properties of your ROOT folder, call the API without rl/{resourceLocation}, as shown in the example below.

    GET https://apis.worksmobile.com/r/{API ID}/drive/v2/files/root
    

    Response - Common Information

    All API requests except the APIs used to upload and download files are delivered to the Drive API server via the API Gateway. When an error related to OAuth authentication occurs, the API Gateway returns an error code.

    {
        "message":"Authentication header not exists",
        "domain":"common",
        "code":"UNAUTHORIZED"
    }
    

    The Drive API server processes the API requests delivered via the API Gateway and returns responses in JSON format.

    {
      "resourceSize" : 106937574,
      "resourceKey" : "MTQ1MDMwMDJ8MTYwOTAwMTg1Njh8RHww",
      "resourceLocation" : null,
      "resourceType" : "folder",
      "resourcePath" : "/123123123123/",
      "fileType" : "folder",
      "folderType" : "my",
      "createDate" : 1430188697000,
      "updateDate" : 1581385436000,
      "accessDate" : 1430188697000,
      "updateUser" : "14503002",
      "hasExif" : false,
      "hasThumbnail" : false,
      "uploaded" : true,
      "locked" : false,
      "virus" : "none",
      "memberShare" : null,
      "linkShare" : null,
      "group" : null,
      "protected" : false
    }
    

    For errors that may occur in the Drive API server, refer to Error Codes.