Perl
Perl
Frame.io - Create a Folder
See more Frame.io Examples
Create a folder asset as a child to the root_asset_id.Chilkat Perl Downloads
use strict;
use warnings;
use Chilkat2;
# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
my $http = Chilkat2::Http->new;
# 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"
# }
my $json = Chilkat2::JsonObject->new;
$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->AuthToken('<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.
my $resp = Chilkat2::HttpResponse->new;
my $success = $http->HttpJson('POST', 'https://api.frame.io/v2/assets/4ecb383f-71a8-4233-b665-d8f75136f554/children', $json, 'application/json', $resp);
if (!$success) {
print $http->LastErrorText, "\n";
exit;
}
my $sbResponseBody = Chilkat2::StringBuilder->new;
$resp->GetBodySb($sbResponseBody);
my $jResp = Chilkat2::JsonObject->new;
$jResp->LoadSb($sbResponseBody);
$jResp->EmitCompact(0);
print "Response Body:\n";
print $jResp->Emit(), "\n";
my $respStatusCode = $resp->StatusCode;
print 'Response Status Code = ', $respStatusCode, "\n";
if ($respStatusCode >= 400) {
print "Response Header:\n";
print $resp->Header, "\n";
print "Failed.\n";
exit;
}
# 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
my $team_id = $jResp->StringOf('team_id');
my $public_item_count = $jResp->IntOf('public_item_count');
my $properties = $jResp->StringOf('properties');
my $deleted_at = $jResp->StringOf('deleted_at');
my $fps = $jResp->StringOf('fps');
my $rating = $jResp->StringOf('rating');
my $description = $jResp->StringOf('description');
my $updated_at = $jResp->StringOf('updated_at');
my $cover_asset_id = $jResp->StringOf('cover_asset_id');
my $archive_scheduled_at = $jResp->StringOf('archive_scheduled_at');
my $subtitle_tracks = $jResp->StringOf('subtitle_tracks');
my $index = $jResp->StringOf('index');
my $item_count = $jResp->IntOf('item_count');
my $account_id = $jResp->StringOf('account_id');
my $name = $jResp->StringOf('name');
my $checksums = $jResp->StringOf('checksums');
my $audio_tracks = $jResp->StringOf('audio_tracks');
my $duration = $jResp->StringOf('duration');
my $label = $jResp->StringOf('label');
my $is_session_watermarked = $jResp->BoolOf('is_session_watermarked');
my $parent_id = $jResp->StringOf('parent_id');
my $versions = $jResp->IntOf('versions');
my $project_id = $jResp->StringOf('project_id');
my $resource_id = $jResp->StringOf('resource_id');
my $v_private = $jResp->BoolOf('private');
my $frames = $jResp->IntOf('frames');
my $autoversion_id = $jResp->StringOf('autoversion_id');
my $v_type = $jResp->StringOf('type');
my $uploaded_at = $jResp->StringOf('uploaded_at');
my $creator_id = $jResp->StringOf('creator_id');
my $user_permissionsCan_download = $jResp->BoolOf('user_permissions.can_download');
my $user_permissionsCan_modify_template = $jResp->BoolOf('user_permissions.can_modify_template');
my $user_permissionsCan_public_share_presentation = $jResp->BoolOf('user_permissions.can_public_share_presentation');
my $user_permissionsCan_public_share_review_link = $jResp->BoolOf('user_permissions.can_public_share_review_link');
my $user_permissionsCan_share_downloadable_presentation = $jResp->BoolOf('user_permissions.can_share_downloadable_presentation');
my $user_permissionsCan_share_downloadable_review_link = $jResp->BoolOf('user_permissions.can_share_downloadable_review_link');
my $user_permissionsCan_share_unwatermarked_presentation = $jResp->BoolOf('user_permissions.can_share_unwatermarked_presentation');
my $user_permissionsCan_share_unwatermarked_review_link = $jResp->BoolOf('user_permissions.can_share_unwatermarked_review_link');
my $shared = $jResp->BoolOf('shared');
my $is_360 = $jResp->BoolOf('is_360');
$v_type = $jResp->StringOf('_type');
my $comment_count = $jResp->IntOf('comment_count');
my $archived_at = $jResp->StringOf('archived_at');
my $filetype = $jResp->StringOf('filetype');
my $id = $jResp->StringOf('id');
my $hard_deleted_at = $jResp->StringOf('hard_deleted_at');
my $copy = $jResp->BoolOf('copy');
my $is_hls_required = $jResp->BoolOf('is_hls_required');
my $archive_status = $jResp->StringOf('archive_status');
my $inserted_at = $jResp->StringOf('inserted_at');
my $filesize = $jResp->IntOf('filesize');