File API
PDF Page 1
Enterprise Development API V6.6 Shanghai Huaqing Information Technology Co., Ltd. Jiang Dajun
PDF Page 2
Directory
- Obtain an enterprise development account .................................................................................................................................................................................4
- Authentication API ................................................................................................................................................................................................. 6
Authentication interface one (login callback method) ..................................................................................................................................................................6 Authentication interface two (login-free method – JWT token method, in private cloud deployment, the jwt token login method needs to be enabled) .................................. 6 Get token .................................................................................................................................................................................................................8 Refresh token ..................................................................................................................................................................................................................8
- File access API...................................................................................................................................................................................................... 8
Get file list ........................................................................................................................................................................................9 Get file information ........................................................................................................................................................................................9 Create a folder .................................................................................................................................................................................................10 Pre-upload files ................................................................................................................................................................................................10 Uploading files .................................................................................................................................................................................................................11 Get the download file address .................................................................................................................................................................................12 Obtain the download address of multiple files .................................................................................................................................................................12 Get the download file thumbnail address .................................................................................................................................................................13 Modify file information .................................................................................................................................................................................13 Modify file name .................................................................................................................................................................................................13 Delete files (to Recycle Bin) ..................................................................................................................................................................................14 Deleting files (from Recycle Bin) ..................................................................................................................................................................14 Empty the Recycle Bin .................................................................................................................................................................................................14 Recovering files (from the Recycle Bin) ..................................................................................................................................................................14 Get all version information of a file .............................................................................................................................................................15 Current version of settings file .............................................................................................................................................................................15 Moving files .................................................................................................................................................................................................15 Copying files .................................................................................................................................................................................................15 Copying file progress ........................................................................................................................................................................................16 File Log .................................................................................................................................................................................................................16 Create library categories .................................................................................................................................................................................17 Create a sublibrary ............................................................................................................................................................................................17 Shared file related API ................................................................................................................................................................................. 17 Get the sharing url of the file ................................................................................................................................................................................. 18 Get the shared permission list .................................................................................................................................................................18 Obtain the sharing role that the user has permission to set for a single file .............................................................................................................................18 Create a link to share .................................................................................................................................................................................18 Turn off link sharing ........................................................................................................................................................................................19 Set link sharing password .................................................................................................................................................................................19 Invite people to share .................................................................................................................................................................19 Get all sharing participants .................................................................................................................................................................20 Set permission roles for sharing participants .............................................................................................................................................................20 Delete sharing participants ........................................................................................................................................................................20 Reminder...................................................................................................................................................................................................21 Remove someone from following .................................................................................................................................................................................21 Get the list of users following a file .................................................................................................................................................................21 Get the list of users who can follow the file and mark the users who have followed the file .............................................................................................21 Enterprise department related API ................................................................................................................................................................................. 22 Obtain current company information ..................................................................................................................................................................22 Obtain information from all departments of the enterprise ........................................................................................................................................................22 Creating a corporate division .................................................................................................................................................................................22 Get a list of department roles .................................................................................................................................................................................23 Add department personnel .................................................................................................................................................................................................23 Delete department personnel ................................................................................................................................................................................................24 Obtain information about your department .................................................................................................................................................................24 Obtain department personnel ................................................................................................................................................................................................24 Adding company members .................................................................................................................................................................................25 Update member information................................................................................................................................................................................25 Obtain enterprise member information .................................................................................................................................................................................26 Get all members of the company .................................................................................................................................................................................26 Obtain enterprise logs .................................................................................................................................................................................................26 Message push API................................................................................................................................................................................................................ 27 Announcement................................................................................................................................................................................................27 Get published announcements ................................................................................................................................................................................27 Send Department Discussion .................................................................................................................................................................................27 Get departmental discussions .................................................................................................................................................................................28 Obtain enterprise logs .................................................................................................................................................................................................28
- JWT token login .................................................................................................................................................................................29
- Appendix - Common API call return status code ............................................................................................................................................................. 30
PDF Page 3
Status code result_code .................................................................................................................................................................................................. 30
PDF Page 4
1. Obtain an enterprise development account
Log in to the Babel Private Cloud Enterprise Management Backend and set up a developer account on the home page: After opening, fill in the callback function address: http://xxx.xxx.xxx.xxx/public/babelAuthResult.do After filling in and clicking OK, the developer ID (client_id) and developer key (client_secret) will be automatically generated: Note: jwtToken is the corresponding encryption key when generating jwtToken.
PDF Page 5
PDF Page 6
2. Authentication API
Authentication interface one (login callback method)
/api/authorize.do
HTTP request method
GET
URL parameters
Parameter name Comment (description) response_type must be code (required) string client_id developer's id (required) string redirect_uri callback function address, needs to be consistent with registration (required) string data: any data, string returned during callback For example: /api/authorize.do?response_type=code&client_id=xxxxx&redirect_uri=http://xxx.xxx.xxx&data=xxx Access via browser Return results If the user is not logged in, it will jump to the login page. After logging in, if it is not authorized, it will 302 jump to the authorization page. If the user has been authorized, it will 302 jump to redirect_uri and bring authorization code and data, similar to http://xxx.xxx.xxx?code=xxx&data=xxx The code is valid for 5 minutes. Authentication interface two (login-free method – JWT token method. In private cloud deployment, the login method of jwt token needs to be enabled. formula)
/api/authorizeByJWT.do
HTTP request method
GET
URL parameters
Parameter name Comment (description) response_type must be code (required) string client_id developer's id (required) string jwt_token Jwt token, (required) string It is a string formed by encrypting {client_id: xxxxxxx} email email (optional), enter the user's email address, log in as this user, leave it blank to log in as an enterprise administrator, string phone phone (optional), enter the user's mobile phone number and log in as this user. Leave it blank to log in as the enterprise administrator. string babelId babelId (optional), pass in the user's work ID, log in as this user, leave it blank to log in as the enterprise administrator, string
PDF Page 7
For example: /api/authorizeByJWT.do?response_type=code&client_id=xxxxx&jwt_token=xxx Note: When using this API, if you do not fill in email, phone, babelId, the system will automatically log in as an administrator, otherwise it will log in as the user corresponding to email, phone, babelId. Log in, the login interface will not be displayed to log in. Note (email, phone, babelId) only needs one of them. Return results { "success": true "code": "xxxxxxxxxxxxxxxxxxxxxxxxxxx", } jwt_token is generated by writing your own program. The sample code is as follows: import java.util.Date; import java.util.HashMap; import java.util.Map; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; import io.jsonwebtoken.Claims; import io.jsonwebtoken.JwtBuilder; import io.jsonwebtoken.Jwts; import io.jsonwebtoken.SignatureAlgorithm; import net.sf.json.JSONObject; /** * Generate token used by standard jwt * */ public class JWT_App { static String skey = "babeldfdfer95840834-t8e-9-9-5934-5943-5886256"; // The key is the jwtToken field filled in the developer account in the Babel backend. public static void main( String[] args ) { HashMap<String, Object> clientInfo = new HashMap<String, Object>(); clientInfo.put("client_id", "7459492016147273"); // is the client_id in the developer account try { String token = createTokenJWT(clientInfo); System.out.println("----> login token:" + token); String token1 = "eyJhbGciOiJIUzI1NiJ9.eyJkdXJhdGlvbiI6NjAsInBheWxvYWQiOnsiY2xpZW50X2lk IjoiNzQ1OTQ5MjAxNjE0NzI3MyJ9LCJ0aW1lIjoxNjkxNDg4MzY4NTk0fQ.pRFCwXd2snMr IgFWOFwYbvyAeeNhoFINGk_Wmv7d24g"; JSONObject parsed = parseTokenJWT(token1); System.out.println("-----> parsed:" + parsed); System.out.println("-----> Just put this token as a parameter in the url, such as: "); } catch (Exception e) { System.out.println(e.getMessage()); } } public static String createTokenJWT(Map<String, Object> config) throws Exception { HashMap<String, Object> data = new HashMap<String, Object>(); data.put("time", new Date().getTime()); data.put("duration", 60); data.put("payload", config); SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256; SecretKey key = generalKey(); JwtBuilder builder = Jwts.builder() .setClaims(data) .signWith(signatureAlgorithm, key); System.out.println( " builder : " + builder); return builder.compact(); } public static JSONObject parseTokenJWT(String jwt) throws Exception { SecretKey key = generalKey(); Claims claims = Jwts.parser() .setSigningKey(key) .parseClaimsJws(jwt) .getBody(); System.out.println("----> claims:" + claims.toString()); Long time = (Long)claims.get("time"); long duration = (Integer)claims.get("duration"); Long now = new Date().getTime(); if (now - time > 1000 * duration) return null; // ------------------- Tokens older than 10 minutes are invalid JSONObject obj = JSONObject.fromObject(claims.get("payload")); return obj; } public static SecretKey generalKey(){ String stringKey = skey; byte[] encodedKey = stringKey.getBytes(); SecretKey key = new SecretKeySpec(encodedKey, 0, encodedKey.length, "HmacSHA256"); return key; } }
PDF Page 8
Get token
/api/token.do
HTTP method: POST
HTTP Header
This interface uses Basic Auth to verify client information. The specific method is to add something like "Authorization: Basic xxxxxxxxx" in the header. Among them "xxxxxxxxx" is calculated from the developer id (client_id) and developer secret key (client_secret). The specific algorithm is Base64Encode(client_id + ":" + client_secret) Base64Encode Choose your own tool for Base64 encoding
URL parameters
Parameter name Comment (description) grant_type (required) must be authorization_code string code (required) Authorization code, that is, the authorization code received by the callback address. The authorization code is valid for 5 minutes. It is used once, regardless of success. If it still fails, the authorization code will become invalid string For example: /api/token.do?grant_type=authorization_code&code=xxx&redirect_uri=http://xxx.xxx.xxx Return results access_token interface access token refresh_token is used to refresh access_token, valid for 30 days The validity time of expires_in access_token, unit is s
Refresh token
/api/refreshToken.do
HTTP method: POST
HTTP Header
This interface uses Basic Auth to verify client information. The specific method is to add something like "Authorization: Basic xxxxxxxxx" in the header. Among them "xxxxxxxxx" is calculated through client_id and client_secret. The specific algorithm is Base64Encode(client_id + ":" + client_secret)
URL parameters
Parameter name Comment (description) grant_type (required) must be refresh_token string refresh_token (required) is the refresh_token string obtained in interface 2 For example: /api/refreshToken.do?grant_type=refresh_token&refresh_token=xxx Return results access_token interface access identification, refresh_token is used to refresh access_token, valid for 30 days The validity time of expires_in access_token is 3600, the unit is s
3. File access API
All interfaces need to carry access_token in the HTTP header when accessing. For interfaces containing request parameters, usually some POST, PUT or DELETE interface, you also need to set Content-Type to specify the format of the parameters. If you need to access different versions of the API, you need Specify a specific version on the request path. If you need to return a response body in a different format, you also need to set Accept. All parameters should be This should use utf-8 encoding.
PDF Page 9
Headers:
Authorization: stores access_token, the format is: "Bearer " + access_token. Content-Type: Indicates the format of the request parameters. If it is a POST, PUT or DELETE request, you need to specify "application/json", I We currently do not support other request parameter formats, such as xml. If it is other types such as GET requests, it does not need to be set in the header. Content-Type. Accept: used to specify the format of the response result and the version information of the api. Currently, only response in json format is supported, so in general Specify "application/json". If the interface access is successful, we will return a response in json format, and the HTTP status code is 200. All successful response responses All json will contain "success: true". The X-Babel-Version in the header of the response indicates the version number of the api accessed by this request.
Get file list
/nd/api/file/list_dir
HTTP method: GET
URL parameters
Parameter name Comment (description) parent_id parent folder id (required) string When parent is 1, returns the contents of the corporate folder, 2 returns the contents of the personal folder, 3 returns my Project, 4 returns the share I added, and other fileId returns the contents of the normal folder. page_size page size number page page number type type: divided into three types: 1 - file, 2 - folder, 0 - all string
Return field description
Attribute name type description files array file information {fileId, name, …} total int total quantity page int page capacity success boolean gets the success mark code int returns error code 0 indicates success
Get file information
/nd/api/file/fileinfo
HTTP method: GET
URL parameters
Parameter name Comment (description) id file id (required) string
Return field description
fileInfo information Attribute name type description file Object file information { id, name, …}
PDF Page 10
success boolean gets the success mark code int returns error code 0 indicates success
Create folder
/nd/api/file/create_folder
HTTP method: POST
POST request body parameters
Parameter name Comment (description) parent_id target folder id (required) string name file name (required) string
Return field description
Attribute name type description file Object file information { id, name, …} success boolean gets the success mark code int returns error code 0 indicates success
Pre-upload files
Used to return the parameters (url, upload_token) required when uploading files in the second step.
/api/file/preUploadFile.do
HTTP method: GET
URL parameters
Parameter name Comment (description) parent_id target folder id (required) (you can ignore this when uploading in the root directory) string name file name (required) string file_id When uploading a new version, you need to specify the new version of the file to upload (you can ignore this when uploading new files) string
The correct return result is as follows
{"upload_token":"92808ecfc2ac4e0ebc0b912edac3be4a","url":"http://testdocument.babel.cc/api/file/uploadPdf.do","su ccess":true,"code":0}
Return field description
Attribute name type description url string This url can only be used once and is valid for 1 hour. Call this url to upload a file. After success, fileId, fileName, version, etc. will be returned. upload_token string is used as a parameter of post when uploading files.
PDF Page 11
Upload files
Note that the URL of this API is returned by the pre-upload interface. There is no specific URL here, just parameter description. https://xxx.xxx.xxx:xxx/api/file/uploadXXX.do (the specific URL is the URL returned by /api/file/preUploadFile.do in the previous section) POST
POST request body parameters
Parameter name Comment (description) file file binary data (upload data) Return value in upload_token /api/file/preUploadFile.do request
The return information is as follows
{"fileId":"7728538212615908","version":0,"fileName":"mesos.pdf","fileSize":848854,"success":true,"code":0} Upload relevant code examples Add ‘com.squareup.okhttp3:okhttp:3.3.1’ package private void uploadFile(final String fileName, String parentId, final DaoCallback<JSONObject> callback){ preUploadFile(fileName, parentId, new DaoCallback<JSONObject>() { @Override public void onSuccess(JSONObject data) { int code = data.optInt("code", -1); final String url = data.optString("url", null); final String uploadToken = data.optString("upload_token"); if (code == 0) { // File file = new File(filePath); RequestBody fileContent = RequestBody.create(MultipartBody.FORM, file); RequestBody requestBody = new MultipartBody.Builder() .setType(MultipartBody.FORM) .addFormDataPart("file", fileName, fileContent) .addFormDataPart("upload_token", uploadToken) .build(); Request request = new Request.Builder() .url(url) .post(requestBody) .build(); // Uploading takes a long time, so you need to set a longer timeout OkHttpClient okHttpClient = new OkHttpClient(); okHttpClient.newCall(request) .enqueue(new okhttp3.Callback() { @Override public void onFailure(okhttp3.Call call, IOException e) { callback.onFailure(-1, null); } @Override public void onResponse(okhttp3.Call call, okhttp3.Response response) throws IOException { int httpCode = response.code(); if (httpCode == 200) { try { JSONObject result = new JSONObject(response.body().string()); response.body().close(); boolean success = result.getBoolean("success"); if (success) { callback.onSuccess(null); } else { int code = result.getInt("code"); String msg = result.optString("msg"); callback.onFailure(code, msg); } } catch (JSONException e) { callback.onFailure(-2, null); } } else { callback.onFailure(httpCode, null); } } }); } } @Override public void onFailure( int errorCode, String msg){ Log.e("FileTransfer", "filePreUpload failed errorCode=" + errorCode); } }); }
PDF Page 12
private void preUploadFile(String fileName, String parentId, final DaoCallback<JSONObject> callback) { String preUploadUrl = "http://private.babel.cc:80/api/file/preUploadFile.do?name=1234.jpg&parent_id=0"; // Pass in the corresponding parameters name, parent-id String authorization = "Bearer d48d0a0e253c4a2985d8c5653f717d71"; //Generate according to the instructions Request request = new Request.Builder().url(preUploadUrl) .addHeader("Authorization", authorization) .build(); OkHttpClient okHttpClient = new OkHttpClient(); okHttpClient.newCall(request).enqueue(new okhttp3.Callback() { @Override public void onFailure(okhttp3.Call call, IOException e) { Log.d("", ""); } @Override public void onResponse(okhttp3.Call call, okhttp3.Response response) throws IOException { Log.d("",""); int httpCode = response.code(); if (httpCode == 200) { JSONObject result = null; try { result = new JSONObject(response.body().string()); } catch (JSONException e) { e.printStackTrace(); } try { boolean success = result.getBoolean("success"); if (success) { String url = result.getString("url"); callback.onSuccess(result); } else { int code = result.getInt("code"); String msg = result.optString("msg"); callback.onFailure(code, msg); } } catch (JSONException e) { callback.onFailure(-2, null); } } else { callback.onFailure(httpCode, null); } } }); }
Get download file address
/api/file/getFileDownloadUrl.do
HTTP method: GET
URL parameters
Parameter name Comment (description) fileId file id to be downloaded (required) string version The version number of the file (optional) number
The return information is as follows
{"code":0,"success":true,"type":"File type","url":"File download address"}
Get download address of multiple files
/api/file/downloadMultiFiles.do
HTTP method: GET
URL parameters
Parameter name Comment (description) fileIdArr is a string composed of the id of the file to be downloaded, separated by the symbol "!" (half-width), for example, the download ids are 133 and 233. file, the value of fileIdArr is "133!233" string type
PDF Page 13
The return information is as follows
{"code":0,"success":true,"type":"File type","url":"File download address"} The return value url is the download address of multiple files packaged.
Get download file thumbnail address
/api/file/downloadThumbnail.do
HTTP method: GET
URL parameters
Parameter name Comment (description) fileId file id to be downloaded (required) string version The version number of the file (optional) number size is the size of the thumbnail to be displayed, taking the maximum value of width and height.
The return information is as follows
{"code":0,"success":true, "url":"File download address"} The return value url is the download address of multiple files packaged.
Modify file information
/nd /api/file/update_file
HTTP method: POST
Modify file information
POST request body parameters
Parameter name Comment (description) file_id file id (required) string name new file name (optional) string description file description (optional) string
The return information is as follows
{"code":0,"success":true}
Modify file name
/nd /api/file/rename
HTTP method: POST
Modify file information
POST request body parameters
Parameter name Comment (description) file_id file id (required) string name new file name string
The return information is as follows
{"code":0,"success":true}
PDF Page 14
Delete files (to recycle bin)
/nd /api/file/remove_file
HTTP method: POST
POST request body parameters
Parameter name Comment (description) file_ids[] target file id array (required) string[]
The return information is as follows
{"code":0,"success":true}
Delete files (from Recycle Bin)
/nd /api/file/remove_from_trash
HTTP method: POST
POST request body parameters
Parameter name Comment (description) file_ids[] target file id array (required) string[]
The return information is as follows
{"code":0,"success":true}
Empty the Recycle Bin
/nd /api/file/empty_trash
HTTP method: POST
POST request body parameters
Parameter name Description
The return information is as follows
{"code":0,"success":true}
Recover files (from Recycle Bin)
/nd /api/file/restore_file
HTTP method: POST
POST request body parameters
Parameter name Comment (description) file_ids[] target file id array string[] restoreAll If file_ids is not filled in, restoreAll is true to restore all files in the recycle bin, boolean
The return information is as follows
PDF Page 15
{"code":0,"success":true}
Get all version information of the file
/nd /api/file/versions
HTTP method: GET
URL parameters
Parameter name Comment (description) file_id target file id (required) string
The return information is as follows
{"code":0,"versions":[],"success":true}
Set the current version of the file
/nd /api/file/version
HTTP method: POST
POST request body parameters
Parameter name Comment (description) file_id target file id (required) string version version number (required) number
The return information is as follows
{"code":0,"success":true}
Move files
/nd /api/file/move
HTTP method: POST
POST request body parameters
Parameter name Comment (description) file_ids Target file id array to be moved (required) string target_id The target folder id that needs to be moved to (required) string
The return information is as follows
{"code":0,"success":true}
Copy files
/nd /api/file/copy
HTTP method: POST
POST request body parameters
Parameter name Comment (description)
PDF Page 16
file_ids Target file id array to be copied (required) string target_id The id of the target folder to be copied to (required) string
The return information is as follows
{ "code": 0, "copyKey": "81427630-054a-11ef-8355-db93b4b1d006", "fileNum": 10, "success": true}
Copy file progress
/nd /api/file/copy_progress
HTTP method: POST
POST request body parameters
Parameter name Comment (description) copyKey Check the copy progress copyKey is returned by the copy interface (required) string
The return information is as follows
{ "code": 0, "completed": 10, "total": 10, "result": {}, "success": true}
File log
/nd /api/file/file_logs
HTTP method: GET
GET request body parameters
Parameter name Comment (description) file_id target file id array (required) string startIndex gets the starting order of logs. Which log should be returned (optional) int defaults to 0. pageSize The number of items returned per page (optional) int type Log type (optional) int Default 0, view all records, 1 only view access records, 2 only view uploads and downloads, 3 only view anonymous users Users, 4 only view sharing and invitations, 5 only view deletion records userName A username (optional) string, returns the log of a certain user lang language (optional) default cn, string language of returned log cn (Chinese) en (English)
The return information is as follows
{"code":0,"success":true, "logs":[], "total":50}
Set whether the user has permission to access the material library
/nd /api/file/ set_user_access_material_library
HTTP method: POST
GET request body parameters
Parameter name Comment (description) userId user's id array type [usrId1, userId2] (required) string can Whether it is accessible Numeric type (required) int Default 0, 0: Inaccessible, 1: Accessible
The return information is as follows
{"code":0,"success":true}
PDF Page 17
Create material library classification
/nd /api/file/create_material_class
HTTP method: POST
POST request body parameters
Parameter name Comment (description) destDirFileId fileId of the destination folder (required) string name The name of the created category library (required) string accessType Classification visibility (optional) Defaults to public 0. 0: // public 1: // Need to apply 2: // Department is public 3: // Department application 4: // Confidential managerIds The id array type of the person in charge [usrId1,userId2] departmentIds Classification visibility-limited department id of department (optional) Array type [departmentId1,departmentId2]
The return information is as follows
{"code":0, "success":true, "materialClass": {}}
Create sub-material library
/nd /api/file/create_material_folder
HTTP method: POST
POST request body parameters
Parameter name Comment (description) destDirFileId fileId of the destination folder (required) string name The name of the created category library (required) string accessType Classification visibility (optional) Defaults to public 0. 0: // public 1: // Need to apply 2: // Department is public 3: // Department application 4: // Confidential managerId The id of the person in charge (optional) string departmentIds Classification visibility-limited department id of department (optional) Array type [departmentId1,departmentId2] assistantIds ID of the material library assistant (optional) Array type [usrId1,userId2]
The return information is as follows
{"code":0, "success":true, "materialFolder": {}}
Shared file related API
PDF Page 18
Get the sharing url of the file
/nd/api/share/shareurl
HTTP method: GET
Get the sharing link of the file (open the sharing first, and then get the link)
URL parameters
Parameter name Comment (description) file_id file id string is_https Whether the returned share_url protocol is https 0 means http, 1 means https, default 0 number
Return field description
{"code":0,"url":"https://private.babel.cc/share.do?s=http://private.babel.cc/share.do?s=MjY2OTYzNTk3OTU2NzEzOTtXZWQgSnVsIDAxIDIwMj AgMTg6MzM6NTAgR01UKzA4MDAgKEhvbmcgS29uZyBTdGFuZGFyZCBUaW1lKQ%3D%3D","success":true}
Get the sharing permission list
/nd/api/share/share_roles
HTTP method: GET
URL parameters
Parameter name Comment (description)
Return field description
{"code":0,"roles":[],"success":true}
Get the sharing roles that the user has permission to set for a single file
/nd/api/share/share_role_forfile
HTTP method: GET
URL parameters
Parameter name Comment (description) file_id file id string
Return field description
{"code":0,"roles":[],"success":true}
Create link to share
/nd/api/share/open_link_share
HTTP method: POST
Open sharing and get a new sharing link. The previous link will be invalid.
PDF Page 19
POST request body parameters
Parameter name Comment (description) file_id pre-shared file id (required) string link_role_id shared role string is_https Whether the returned share_url protocol is https number anonymousVisit Whether to allow anonymous access, 1 means allowed, 0 means not allowed (optional, default is 1) number
Return field description
{"code":0,"share_url":"http://private.babel.cc/share.do?s=http://private.babel.cc/share.do?s=MjY2OTYzNTk3OTU2NzEzOTtXZWQgSnV sIDAxIDIwMjAgMTg6MzM6NTAgR01UKzA4MDAgKEhvbmcgS29uZyBTdGFuZGFyZCBUaW1lKQ%3D%3D","password":"","success":tru e}
Close link sharing
/nd/api/share/close_link_share
HTTP method: POST
Close the shared link I opened
POST request body parameters
Parameter name Comment (description) file_id shared file id (required) string
Return field description
{"code":0,"success":true}
Set link sharing password
/nd/api/share/set_share_password
HTTP method: POST
File link sharing is turned on, set a password for link sharing.
POST request body parameters
Parameter name Comment (description) file_id pre-shared file id (required) string password password for link sharing string is_https Whether the returned share_url protocol is https number
Return field description
{"code":0,"success":true, "share_url": "http://private.babel.cc/share.do?s=xxxxxxxxxxx"}
Invite people to share
/nd/api/share/invite_share
HTTP method: POST
PDF Page 20
You can invite certain people to access files based on the user's email or mobile phone
POST request body parameters
Parameter name Comment (description) file_id file id (required) string share_role ID of the shared permission (all the above people share this permission) (required) string emails[] email array string[] phones[] array of mobile phone numbers string[]
Return field description
{"code":0,"success":true}
Get all sharing participants
/nd/api/share/share_participants
HTTP method: GET
URL parameters
Parameter name Comment (description) file_id file id (required) string
Return field description
{"code":0,"users":[],"success":true}
Set permission roles for sharing participants
/nd/api/share/set_participant_role
HTTP method: POST
POST request body parameters
Parameter name Comment (description) file_id file id (required) string babelshare_id int (required) user id string role_id int (required) role id string
Return field description
{"code":0,"success":true}
Delete sharing participants
/nd/api/file/remove_share_participant
HTTP method: POST
POST request body parameters
Parameter name Comment (description)
PDF Page 21
file_id file id (required) string babelshare_ids[] int (required) user id string
Return field description
{"code":0,"success":true}
Reminder
/nd/api/file/focus_file
HTTP method: POST
POST request body parameters
Parameter name Comment (description) file_id file id (required) string user_ids[] The id of the user to be reminded. This id should be selected among the file participants, otherwise the reminder will not work (required) string[]
Return field description
{"code":0,"success":true}
Remove someone’s attention
/nd/api/file/unfocus_file
HTTP method: POST
POST request body parameters
Parameter name Comment (description) file_id file id (required) string user_ids[] The id of the user to be reminded. This id should be selected among the file participants, otherwise the reminder will not work (required) string[]
Return field description
{"code":0,"success":true}
Get the list of users following the file
/nd/api/file/user_focusfile
HTTP method: GET
URL parameters
Parameter name Comment (description) file_id file id (required) string
Return field description
{"code":0,"users":[],"success":true}
Get the list of users who can follow the file, and mark the users who have followed the file
/nd/api/file/user_can_focusfile
PDF Page 22
HTTP method: GET
URL parameters
Parameter name Comment (description) file_id file id (required) string
Return field description
Enterprise department related API
Get current enterprise information
/nd/api/enterprise/current
HTTP method: GET
URL parameters
Parameter name Comment (description) None
Return field description
{"code":0,"enterprise":{},"success":true}
Get information about all departments of the enterprise
/nd/api/enterprise/departments
HTTP method: GET
URL parameters
Parameter name Comment (description) None
Return field description
Attribute name type description departments [] array returns all department information tree {}json data returns the parent-child structure information of the department code int successboolean
Create enterprise department
/nd/api/enterprise/create_department
HTTP method: POST
PDF Page 23
POST request body parameters
Parameter name Comment (description) parent_dep parent department id, 0 means following department (required) string name department name (required) string description department description string
Return field description
Attribute name type description department {} json data structure code int successboolean
Get the list of department roles
/nd/api/enterprise/dep_role
HTTP method: GET
URL parameters
Parameter name Comment (description)
Return field description
Attribute name type description roles []array { id, filePermission,enterpriseId,filePermission,managerPermission, default,nameEn,name} code int successboolean
Add department personnel
/nd/api/enterprise/add_dep_mem
HTTP method: POST
POST request body parameters
Parameter name Comment (description) department_id department id (required) string user_ids[] user list string[] role_id The user's role in the department string
PDF Page 24
Return field description
Attribute name type description
Delete department personnel
/nd/api/enterprise/remove_dep_mem
HTTP method: POST
POST request body parameters
Parameter name Comment (description) department_id department id (required) string user_ids[] Person’s id (required) string[]
Return field description
Attribute name type description
Get information about your department
/nd/api/enterprise/mydeparments
HTTP method: GET
URL parameters
Parameter name Comment (description) None
Return field description
Attribute name type description departments [] array returns my department information code int successboolean
Get department personnel
/nd/api/enterprise/departmentmembers
PDF Page 25
HTTP method: GET
URL parameters
Parameter name Comment (description) department_id department id (required) string
Return field description
Attribute name type description users array: {id, name, avatrUrl,}
Add company members
/nd/api/enterprise/add_ent_mem
HTTP method: POST
POST request body parameters
Parameter name Comment (description) email Email mailbox string password password string enterprise_role enterprise member role, optional number department_ids[] The user's department, optional string[] department_roles[] Roles in the department, optional string[] sex 0 - not set 1 - male 2 - female number name username string phone mobile phone number, optional string babelId employee ID, optional string spacelimit personal space limit, unit GB, 0 means no limit number can_ownfile whether the user can have personal files, -1 - use the overall enterprise settings, 0 - no personal files, 1 - have personal files number remarks user description, optional string join_time The time when the user joined the enterprise, Unix time, unit number seconds password_is_md5 Whether the incoming password requires md5 encryption, 0 non-md5 password, 1 md5 encrypted password number
Update member information
/api/updateUserInfo.do
HTTP method: POST
POST request body parameters
Parameter name Comment (description) email email address (search keyword, required) string password password (change password, optional) string frozen 1 – means frozen, 0 – means unfrozen (freeze the account, optional) number password_is_md5 Whether the incoming password requires md5 encryption, 0 non-md5 password, 1 md5 encrypted password number phone mobile phone number (optional) string
PDF Page 26
Get enterprise member information
/api/getEnterpriseMember.do
HTTP method: GET
URL parameters
Parameter name Comment (description) email email address (search keyword) string phone mobile phone number (search keyword) string babelId employee number (search keyword) string email/phone/babelId you can choose one
Return field description
{"code":0,"success":true,"user":{}}
Get all members of the company
/nd/api/enterprise/enterprise_members
HTTP method: POST
POST request body parameters
Parameter name Comment (description) lang language type, cn Chinese, en English, optional options { departmentId: //Department id, if not filled in, it means all employees of the enterprise roleId: // Role id, if not filled in, there is no role limit "userType": 0, // 0 - internal personnel, 1 - external personnel "keyName": "", // Search keywords: name, mobile phone number, email address, if not filled in, it means all people "startIndex": 0, "pageSize": 20, status: // 0 - all accounts, 1 - deactivated accounts } Optional
Return field description
{"code":0,"success":true,"members":{},"total":xx}
Get enterprise logs
/nd/api/enterprise/enterprise_logs
HTTP method: POST
POST request body parameters
Parameter name Comment (description) department_id department id, if not filled in, it will be the log of all departments string optional keyword related search keyword string optional
PDF Page 27
startTime log starting time number optional endTime log end time number optional startIndex int optional pageSize int optional
Return field description
{"code":0,"success":true,"logs":{},"total":xx}
Message Push API
Make an announcement
/nd/api/enterprise/broadcast
HTTP method: POST
POST request body parameters
Parameter name Comment (description) title Announcement content string (required) string content content (required) string target_users[] UserId array, if empty, it means all users will receive it, string[] target_deps[] Target department, all members of this department and sub-departments will receive notification, string[] Target_users and target_deps must be filled in at least 1
Return field description
{"code":0,"success":true}
Get published announcements
/nd/api/enterprise/broadcast
HTTP method: GET
URL parameters
Parameter name Comment (description) start_index number pagesize number
Return field description
{"code":0,"broadcasts":[],"total":19,"success":true}
Send department discussion
/nd/api/file/send_dep_discussion
HTTP method: POST
PDF Page 28
POST request body parameters
Parameter name Comment (description) dep_id department id (required) string message information character (required) string json string, format {Type: “Text”, Body: “Hello” }
Return field description
{"code":0,"messageId":99,"success":true}
Get department discussion
/nd/api/file/dep_discussion
HTTP method: POST
POST request body parameters
Parameter name Comment (description) dep_id department id (required) string pagesize page size string start_id message id, only the messages before this message will be obtained, if it is empty, the latest message will be obtained string
Return field description
{"msgArr":[],"gotMoreMessages":1,"code":0,"success":true}
Get enterprise logs
/nd/api/enterprise/enterprise_logs
HTTP method: GET
URL parameters
Parameter name Comment (description) department_id department id() string pagesize page size number, default value 1000 start_index message starting position, number keyword log keyword string startTime start date: seconds number endTime expiration date seconds number
Return field description
{"logs":[],"total":0,"code":0,"success":true} total returns all those that meet the conditions (regardless of paging pageSize)
PDF Page 29
4. JWT token login
In private cloud deployment, the login method of jwt token can be enabled. In this case, the following url is allowed to directly enter the network disk system as a user without logging in. System:
/account/tokenLogin.do
Parameters: Parameter name Optional Description Optional value Default value userToken is required and contains the encrypted information of the logged in user (Constructor None See the instructions below for details) fileId optional The id of the file (folder) to be accessed, if not None If filled in, the user root directory will be opened. closeTitleBar optional Whether to close the title bar 1 - Close 0 - Do not close 0 disableEntMark Optional Whether to hide the corporate logo in the upper left corner 1 - Hide 0 - Do not hide 0 disableUserMark Optional Whether to hide the user settings entrance in the upper right corner 1 - Hide 0 - Do not hide 0 defaultLang optional Set the language used by the interface cn Chinese en English zh-HK Traditional cn defaultClrTheme is optional and sets the interface color theme. normal is the standard mode, dark is the dark mode normal. For example, the following is the user root interface in English and dark mode with the user logo in the upper right corner hidden.
/account/tokenLogin.do
userToken=xxxxxxxxxxxxxxxx defaultClrTheme=dark defaultLang=en disableUserMark=1 Construction of userToken userToken is an encrypted string containing logged-in user information. The encrypted information is a password created by JWT, a standard security mechanism for transmitting trusted data between two parties. The content of JWT encrypted user information JSONObject is as follows: { payload: { email: “xxx@xxx.com”/“135XXXXXXX”/“XXXX”} time: now } Note: email can be an email address, mobile phone number, or work number; The code is as follows: public static void main( String[] args ) { HashMap<String, Object> user = new HashMap<String, Object>(); user.put("email", "yuanchaozhao@qq.com"); try { //token login String userToken = createTokenJWT(user); System.out.println("----> login token:" + userToken); JSONObject parsed = parseTokenJWT(userToken); System.out.println("-----> parsed:" + parsed); System.out.println("-----> Just put this token as a parameter in the url, such as: "); System.out.println("/account/tokenLogin.do?userToken=" + userToken); } catch (Exception e) { System.out.println(e.getMessage()); } } For other codes, please refer to the jwtToken generation code, which is provided in the authentication interface 2. Remarks: JWT is the abbreviation of JSON Web Tokens. It is a communication encryption and decryption mechanism that meets the industry standard RFC7519. Please refer to: https://jwt.io/
PDF Page 30
5. Appendix - Common API call return status code
Status code result_code
Code value Description 0 success 1 unknown error 2 parameter error 7 Not enough space 12 Prohibited user actions 13 invalid token ---------------------------------- the end ----------------------------------