Drive API Overview

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

    Preparations

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

    Getting an API ID

    An "API ID" is used in the Drive API's request URL. For how to get your API ID, see API Common Guide.

    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 API Common Guide.

    How to Use

    Add the 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."

    method.setRequestHeader("Authorization", "Bearer AAAA…");
    method.setRequestHeader("consumerKey", "AbCdEfGhIjKlMn");
    

    Sample Code for Java

    String url = "https://apis.worksmobile.com/{API ID}/drive/getQuota/v1";
    HttpClient client = new HttpClient();
    HttpMethod method = new GetMethod(url);
    method.setRequestHeader("Authorization", "Bearer AAAA8…");
    method.setRequestHeader("consumerKey", "AbCdEfGhIjKlMn");
    client.executeMethod(method);
    LOGGER.debug("result : {}", method.getResponseBodyAsString());
    

    API Common Information

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

    Response Common

    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.

    {
    "errorCode":"028",
    "errorMessage":"Authentication header not exists"
    }
    

    The Drive API server processes the API requests delivered via the API Gateway and returns responses in JSON format. The response is subdivided into code, message and result; the actual result value is included in "result."

    {
      "code" : "0",
      "message" : "success",
      "result" : {
        "cycle" : 30,
        "size" : 50000
      }
    }
    

    Result Code

    The Drive API server returns 0 if an API request succeeds, and an error code if it fails. The following table shows error codes returned when an API request except the APIs to upload and download files fails.

    Table 1 Error codes returned when an API request fails (except the APIs to upload and download files)

    Category Error code Error message Description
    Common 1000 Internal Server Error Internal server error
    1001 Invalid Parameters Parameter error
    1002 Service Not Available LINE WORKS Drive service is not available
    1003 File operation API not Available File operation API (copy and move files, change file name, create a folder, etc.) is not available
    1004 Not Supported Operation The operation is not supported.
    1005 Your request is currently being processed. You can check again later to see the request has been processed. This error code is returned when the amount of time the file operation API is processed is over 30 seconds. Even though the time to process the API exceeds 30 seconds, the API request is still likely to succeed.
    1006 Private folder not available Private folder is not available.
    1101 Works Domain is Not Active LINE WORKS domain is not active.
    1102 Works Drive Service is Not Active LINE WORKS Drive service is not active.
    Authentication error 2001 Authentication Fail Authentication error (Login is required)
    2003 Read Only User Read-only user account.
    2004 ID Change Fail An error occurred while changing the user ID.
    2005 Not Supported During Storage Move (Change of tenant IDC) Not supported during OwFS migration.
    Account error 2101 Not Registered User The user is not a member of LINE WORKS Drive.
    2105 Forbidden User The user is not authorized to access the service.
    2106 Share Forbidden user The user is not authorized to use Share.
    2107 Multi IP Access Forbidden User The user uses multiple IP addresses to access the service.
    Resource does not exist 3101 Resource Not Exist The resource does not exist.
    3102 Folder Not Exist The folder does not exist.
    3103 File Not Exist The file does not exist.
    3104 Source Resource Not Exist The source resource does not exist.
    3105 Destination Resource Not Exist The destination resource does not exist.
    3111 Share Folder Not Exist The shared folder does not exist.
    Resource already exists 3201 Resource already Exist The resource already exists.
    3202 Folder already Exist The folder already exists.
    3203 File already Exist The file already exists.
    3204 File Name Same as Input Folder Name Exist The folder name is the same as an existing file name.
    3205 Folder Name Same as Input File Name Exist The file name is the same as an existing folder name.
    3206 Duplicated Share Folder Exist The shared folder already exists.
    Protected resource already exists 3211 Protected Folder Exist The protected folder exists.
    3212 Protected File Exist The protected file exists.
    3213 Protected Share Folder Exist The protected shared folder exists.
    3214 Protected Share File Exist The protected shared file exists.
    3215 Protected Resource Exist in Sub Folder The protected resource exists in the sub folder.
    Other errors 3301 Exceeds Data Capacity Drive capacity exceeded.
    3302 Over Max Folder Name Length The length of the folder name is too long.
    3303 Over Max File Name Length The length of the file name is too long.
    3304 Over Total Path Length The length of the path is too long.
    3305 Invalid Resource Path Invalid resource path
    3306 Resource Lock Resource locked.
    3402 Virus File Virus file
    3403 Blocked Extension File The type of file restricted from being uploaded or downloaded.
    Shared folder or group folder errors 4101 Auth Fail Shared folder or group folder permission error
    4102 Write Permission Needed Write permission is required.
    4103 Not Supported In Share/Group Folder The function is not supported in shared folder or group folder.
    4104 Exceed Share User Count The number of shared users exceeded.
    4105 Already Shared or Authorized Folder Already shared or authorized folder.
    4106 Exceed Share Folder Count The maximum number of folder shares exceeded.

    Note

    • More error codes can be added later, but it is recommended to handle errors related to "Resource does not exist" and "Resource already exists" as specified in the "Table 1."

    The following table shows error codes returned when an API request to upload or download files fails.

    Table 2 Error codes returned when an API request to upload or download files fails

    Error code Error message Description
    10000 System Error Internal system error
    1216 Share Folder Not a shared folder.
    1600 WORKS AUTH FAIL No permissions to access LINE WORKS.
    1120 Auth Fail No permissions to upload files or invalid share.
    1210 Need Write Auth No write permissions.
    1001 Parent Folder Not Found Parent folder is not found.
    1042 Total Path(Max) Size Over The length of the path is too long.
    1063 Total Name(Max) Size Over The length of the file name is too long.
    1007 Exist Protected File The target file is protected (when the upload type is "append")
    1009 Duplicated File Exist The target file already exists (when the upload type is "append")
    1059 Folder Lock Upload folder is locked.
    1003 Over Upload Quota Insufficient user upload quota
    1022 Over Quota File Size Limited file size exceeded.
    1016 Not Allowed Name Name format not supported.
    1202 Not Exist Shared Folder No shared folder exists.
    1068 Client File Lock The target file is locked by another client.
    1011 Not Exist Path No file (or folder) exists.
    1036 File Information Not Found No file information exists.
    1037 Folder Information Not Found No folder information exists.
    1071 Virus File Fail Virus file – access restricted
    1076 Restrict Upload File Extension File types that cannot be uploaded to the domain
    2001 File Storage Error Storage device error
    2002 Invalidation Cookie Invalid authentication information entered for upload or download