Update Files API
This API is used to update files in modules of courses or batches in LMS
Request URL: (Self Paced Course)
https://people.zoho.com/api/v1/courses/<courseId>/modules<moduleId>/files/<fileId>?fileData={"name" : <name>, "file" : <file>, "duration" :<duration>, "description" : <description>, "isMandatory" : <isMandatory>, "isIntroFile" : <isIntroFile>, "enableDownload" : <enableDownload>, "lockUntil" : <lockUntil>}
Request URL: (Blended Learning Course)
https://people.zoho.com/api/v1/courses/<courseId>/batches/<batchId>/modules<moduleId>/files/<fileId>?fileData={"name" : <name>, "file" : <file>, "duration" :<duration>, "description" : <description>, "isMandatory" : <isMandatory>, "isIntroFile" : <isIntroFile>, "enableDownload" : <enableDownload>, "lockUntil" : <lockUntil>}
Scope:
ZOHOPEOPLE.training.ALL
OR
ZOHOPEOPLE.training.UPDATE
Possible Operation Types:
ALL - Complete access to data
UPDATE - Only to update data
Method:
PATCH
Request Parameters
Parameters | Values Allowed | Default Value | Description |
*fileData | <parameters in JSON Object> | JSON Input |
Parameters | Values Allowed | Default Value | Description |
name | <file name> | <Mandatory> | Specify the file name |
file | <File> | <Mandatory> | Specify the file |
duration | <Duration in minutes> | - | Specify the duration |
description | <Description> | - | Specify the description |
isMandatory | <true|false> | true | Specify if the file is mandatory or not |
isIntroFile | <true|false> | false | Specify if the file is intro file or not |
enableDownload | <true|false> | true | Specify if the file can be downloaded or not |
lockUntil | <lockUntil date in DD-MM-YYYY format> | - | Specify the lockUntil date |
resources | <files> | - | Specify resources |
*mandatory parameters
Error Codes and Descriptions
Status Codes | Description |
---|---|
400 | Invalid parameter value/input parameter missing |
403 | Sorry! You are not authorized to do this operation |
404 | Not found |
422 | Maximum limit exceeded |
500 | Sorry! Server error occured |
View complete list of LMS API error codes
Threshold Limit: 30 requests | Lock period: 5 minutes
Threshold Limit - Number of API calls allowed within a minute.
Lock Period - Wait time before consecutive API requests.
Request
Copiedimport okhttp3.*;
public class Main {
public static void main(String[] args) throws Exception {
OkHttpClient client = new OkHttpClient();
String jsonData = "{\"name\":\"updateFile API Testing\",\"duration\":100,\"description\":\"File API testing\",\"isMandatory\":true,\"isIntroFile\":true,\"enableDownload\":true}";
Request request = new Request.Builder()
.url("https://people.zoho.com/api/v1/courses/478346000019007001/modules/478346000019007013/files/478346000019582003")
.patch(RequestBody.create(MediaType.parse("application/json"), jsonData))
.addHeader("Authorization", "Zoho-oauthtoken YOUR_ACCESS_TOKEN")
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
}
}
Copiedconst url = "https://people.zoho.com/api/v1/courses/478346000019007001/modules/478346000019007013/files/478346000019582003";
const data = {
name: "updateFile API Testing",
duration: 100,
description: "File API testing",
isMandatory: true,
isIntroFile: true,
enableDownload: true
};
fetch(url, {
method: "PATCH",
headers: {
"Authorization": "Zoho-oauthtoken YOUR_ACCESS_TOKEN",
"Content-Type": "application/json"
},
body: JSON.stringify(data)
})
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.error("Error:", error));
Copiedcurl -X PATCH "https://people.zoho.com/api/v1/courses/478346000019007001/modules/478346000019007013/files/478346000019582003" \
-H "Authorization: Zoho-oauthtoken YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "updateFile API Testing",
"duration": 100,
"description": "File API testing",
"isMandatory": true,
"isIntroFile": true,
"enableDownload": true
}'
Copiedurl = "https://people.zoho.com/api/v1/courses/478346000019007001/modules/478346000019007013/files/478346000019582003";
headers = map();
headers.put("Authorization", "Zoho-oauthtoken YOUR_ACCESS_TOKEN");
headers.put("Content-Type", "application/json");
data = map();
data.put("name", "updateFile API Testing");
data.put("duration", 100);
data.put("description", "File API testing");
data.put("isMandatory", true);
data.put("isIntroFile", true);
data.put("enableDownload", true);
response = invokeurl
[
url : url
type : PATCH
headers: headers
parameters: data
];
info response;
Copiedimport requests
url = "https://people.zoho.com/api/v1/courses/478346000019007001/modules/478346000019007013/files/478346000019582003"
payload = {
"name": "updateFile API Testing",
"duration": 100,
"description": "File API testing",
"isMandatory": True,
"isIntroFile": True,
"enableDownload": True
}
headers = {
"Authorization": "Zoho-oauthtoken YOUR_ACCESS_TOKEN",
"Content-Type": "application/json"
}
response = requests.patch(url, headers=headers, json=payload)
print(response.text)
Show full
Show less
Header
CopiedAuthorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxx9be93.9b8xxxxxxf
Response
Copied{
"code": 200,
"file": {
"isMandatoryFile": true,
"fileName": "File One_update",
"previewURL": "",
"canMarkAsComplete": 0,
"description": "Description for File",
"resources": [],
"canUserDelete": true,
"duration": "100 Mins",
"lockUntil": "27-12-2021",
"isDownloadable": true,
"isIntroFile": true,
"isLocked": true,
"canUserEdit": true,
"moduleId": "219225000000648001",
"fileId": "219225000000648115"
},
"message": "success"
}
Show full
Show less