Java
Chilkat2 Java
Frame.io - Create a Folder
See more Frame.io Examples
Create a folder asset as a child to the root_asset_id.Chilkat Java Downloads
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.Http;
import com.chilkatsoft.chilkat2.HttpResponse;
import com.chilkatsoft.chilkat2.JsonObject;
import com.chilkatsoft.chilkat2.StringBuilder;
public class ChilkatExample {
public static void main(String[] args) {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Http http = new Http();
// Implements the following CURL command:
// curl --request POST \
// --url https://api.frame.io/v2/assets/<root_asset_id>/children \
// --header 'authorization: Bearer <FRAME_IO_DEV_TOKEN>' \
// --header 'content-type: application/json' \
// --data '{"type":"folder", "name": "Folder at root"}'
// Use the following online tool to generate HTTP code from a CURL command
// Convert a cURL Command to HTTP Source Code
// Use this online tool to generate code from sample JSON:
// Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "type": "folder",
// "name": "Folder at root"
// }
JsonObject json = new JsonObject();
json.updateString("type", "folder");
json.updateString("name", "Folder at root");
http.setRequestHeader("content-type", "application/json");
// Adds the "Authorization: Bearer <FRAME_IO_DEV_TOKEN>" header.
http.setAuthToken("<FRAME_IO_DEV_TOKEN>");
// Our root_asset_id = 4ecb383f-71a8-4233-b665-d8f75136f554
// You'll need to modify the following line to use your root asset ID.
HttpResponse resp = new HttpResponse();
try {
http.httpJson("POST", "https://api.frame.io/v2/assets/4ecb383f-71a8-4233-b665-d8f75136f554/children", json, "application/json", resp);
} catch (ChilkatException e) {
System.out.println(e.getLastErrorText());
return;
}
StringBuilder sbResponseBody = new StringBuilder();
resp.getBodySb(sbResponseBody);
JsonObject jResp = new JsonObject();
jResp.loadSb(sbResponseBody);
jResp.setEmitCompact(false);
System.out.println("Response Body:");
System.out.println(jResp.emit());
int respStatusCode = resp.getStatusCode();
System.out.println("Response Status Code = " + respStatusCode);
if (respStatusCode >= 400) {
System.out.println("Response Header:");
System.out.println(resp.getHeader());
System.out.println("Failed.");
return;
}
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "team_id": "95a5fbad-688d-46fc-aef1-2f011dd76c10",
// "public_item_count": 0,
// "properties": null,
// "deleted_at": null,
// "fps": null,
// "rating": null,
// "description": null,
// "updated_at": "2020-08-18T03:31:59.699011Z",
// "cover_asset_id": null,
// "archive_scheduled_at": null,
// "subtitle_tracks": null,
// "index": -7.0,
// "item_count": 0,
// "account_id": "b1cd046b-a3bf-4ef8-81a6-0afd74ecc455",
// "name": "FolderA",
// "checksums": null,
// "audio_tracks": null,
// "duration": null,
// "label": "none",
// "is_session_watermarked": false,
// "parent_id": "4ecb383f-71a8-4233-b665-d8f75136f554",
// "versions": 0,
// "project_id": "e76653c4-6cc0-4c47-936b-f7885b477dc0",
// "resource_id": null,
// "private": false,
// "frames": 0,
// "autoversion_id": null,
// "type": "folder",
// "uploaded_at": "2020-08-18T03:31:59.697174Z",
// "creator_id": "34b4f98a-7cc9-4159-8f46-c7c3d837fc6f",
// "user_permissions": {
// "can_download": true,
// "can_modify_template": false,
// "can_public_share_presentation": true,
// "can_public_share_review_link": true,
// "can_share_downloadable_presentation": true,
// "can_share_downloadable_review_link": true,
// "can_share_unwatermarked_presentation": true,
// "can_share_unwatermarked_review_link": true
// },
// "shared": false,
// "is_360": false,
// "_type": "folder",
// "comment_count": 0,
// "archived_at": null,
// "filetype": null,
// "id": "039845e8-bffe-4d6b-88d3-c780bae06342",
// "hard_deleted_at": null,
// "copy": false,
// "is_hls_required": false,
// "archive_status": null,
// "inserted_at": "2020-08-18T03:31:59.699011Z",
// "filesize": 0
// }
// Sample code for parsing the JSON response...
// Use the following online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
String team_id = jResp.stringOf("team_id");
int public_item_count = jResp.intOf("public_item_count");
String properties = jResp.stringOf("properties");
String deleted_at = jResp.stringOf("deleted_at");
String fps = jResp.stringOf("fps");
String rating = jResp.stringOf("rating");
String description = jResp.stringOf("description");
String updated_at = jResp.stringOf("updated_at");
String cover_asset_id = jResp.stringOf("cover_asset_id");
String archive_scheduled_at = jResp.stringOf("archive_scheduled_at");
String subtitle_tracks = jResp.stringOf("subtitle_tracks");
String index = jResp.stringOf("index");
int item_count = jResp.intOf("item_count");
String account_id = jResp.stringOf("account_id");
String name = jResp.stringOf("name");
String checksums = jResp.stringOf("checksums");
String audio_tracks = jResp.stringOf("audio_tracks");
String duration = jResp.stringOf("duration");
String label = jResp.stringOf("label");
boolean is_session_watermarked = jResp.boolOf("is_session_watermarked");
String parent_id = jResp.stringOf("parent_id");
int versions = jResp.intOf("versions");
String project_id = jResp.stringOf("project_id");
String resource_id = jResp.stringOf("resource_id");
boolean v_private = jResp.boolOf("private");
int frames = jResp.intOf("frames");
String autoversion_id = jResp.stringOf("autoversion_id");
String v_type = jResp.stringOf("type");
String uploaded_at = jResp.stringOf("uploaded_at");
String creator_id = jResp.stringOf("creator_id");
boolean user_permissionsCan_download = jResp.boolOf("user_permissions.can_download");
boolean user_permissionsCan_modify_template = jResp.boolOf("user_permissions.can_modify_template");
boolean user_permissionsCan_public_share_presentation = jResp.boolOf("user_permissions.can_public_share_presentation");
boolean user_permissionsCan_public_share_review_link = jResp.boolOf("user_permissions.can_public_share_review_link");
boolean user_permissionsCan_share_downloadable_presentation = jResp.boolOf("user_permissions.can_share_downloadable_presentation");
boolean user_permissionsCan_share_downloadable_review_link = jResp.boolOf("user_permissions.can_share_downloadable_review_link");
boolean user_permissionsCan_share_unwatermarked_presentation = jResp.boolOf("user_permissions.can_share_unwatermarked_presentation");
boolean user_permissionsCan_share_unwatermarked_review_link = jResp.boolOf("user_permissions.can_share_unwatermarked_review_link");
boolean shared = jResp.boolOf("shared");
boolean is_360 = jResp.boolOf("is_360");
v_type = jResp.stringOf("_type");
int comment_count = jResp.intOf("comment_count");
String archived_at = jResp.stringOf("archived_at");
String filetype = jResp.stringOf("filetype");
String id = jResp.stringOf("id");
String hard_deleted_at = jResp.stringOf("hard_deleted_at");
boolean copy = jResp.boolOf("copy");
boolean is_hls_required = jResp.boolOf("is_hls_required");
String archive_status = jResp.stringOf("archive_status");
String inserted_at = jResp.stringOf("inserted_at");
int filesize = jResp.intOf("filesize");
}
}