Sample code for 30+ languages & platforms
Pascal (Lazarus/Delphi)

Frame.io - Create a Folder

See more Frame.io Examples

Create a folder asset as a child to the root_asset_id.

Chilkat Pascal (Lazarus/Delphi) Downloads

Pascal (Lazarus/Delphi)
program ChilkatDemo;

// Demonstrates using the Chilkat Pascal wrapper via the C bridge DLL.
// Builds as a console application under Lazarus (FPC) or Delphi.

{$IFDEF FPC}
  {$MODE DELPHI}
{$ENDIF}
{$APPTYPE CONSOLE}

uses
  {$IFDEF UNIX}
  cthreads,
  {$ENDIF}
  SysUtils,
  CkDllLoader,
  Chilkat.Http,
  Chilkat.StringBuilder,
  Chilkat.HttpResponse,
  Chilkat.JsonObject;

// ---------------------------------------------------------------------------

procedure RunDemo;
var
  success: Boolean;
  http: THttp;
  json: TJsonObject;
  resp: THttpResponse;
  sbResponseBody: TStringBuilder;
  jResp: TJsonObject;
  respStatusCode: Integer;
  team_id: string;
  public_item_count: Integer;
  properties: string;
  deleted_at: string;
  fps: string;
  rating: string;
  description: string;
  updated_at: string;
  cover_asset_id: string;
  archive_scheduled_at: string;
  subtitle_tracks: string;
  index: string;
  item_count: Integer;
  account_id: string;
  name: string;
  checksums: string;
  audio_tracks: string;
  duration: string;
  label: string;
  is_session_watermarked: Boolean;
  parent_id: string;
  versions: Integer;
  project_id: string;
  resource_id: string;
  v_private: Boolean;
  frames: Integer;
  autoversion_id: string;
  v_type: string;
  uploaded_at: string;
  creator_id: string;
  user_permissionsCan_download: Boolean;
  user_permissionsCan_modify_template: Boolean;
  user_permissionsCan_public_share_presentation: Boolean;
  user_permissionsCan_public_share_review_link: Boolean;
  user_permissionsCan_share_downloadable_presentation: Boolean;
  user_permissionsCan_share_downloadable_review_link: Boolean;
  user_permissionsCan_share_unwatermarked_presentation: Boolean;
  user_permissionsCan_share_unwatermarked_review_link: Boolean;
  shared: Boolean;
  is_360: Boolean;
  comment_count: Integer;
  archived_at: string;
  filetype: string;
  id: string;
  hard_deleted_at: string;
  copy: Boolean;
  is_hls_required: Boolean;
  archive_status: string;
  inserted_at: string;
  filesize: Integer;

begin
  success := False;

  //  This example assumes the Chilkat API to have been previously unlocked.
  //  See Global Unlock Sample for sample code.

  http := THttp.Create;

  //  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"
  //  }

  json := TJsonObject.Create;
  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.

  resp := THttpResponse.Create;
  success := http.HttpJson('POST','https://api.frame.io/v2/assets/4ecb383f-71a8-4233-b665-d8f75136f554/children',json,'application/json',resp);
  if (success = False) then
    begin
      WriteLn(http.LastErrorText);
      Exit;
    end;

  sbResponseBody := TStringBuilder.Create;
  resp.GetBodySb(sbResponseBody);
  jResp := TJsonObject.Create;
  jResp.LoadSb(sbResponseBody);
  jResp.EmitCompact := False;

  WriteLn('Response Body:');
  WriteLn(jResp.Emit());

  respStatusCode := resp.StatusCode;
  WriteLn('Response Status Code = ' + respStatusCode);
  if (respStatusCode >= 400) then
    begin
      WriteLn('Response Header:');
      WriteLn(resp.Header);
      WriteLn('Failed.');
      Exit;
    end;

  //  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

  team_id := jResp.StringOf('team_id');
  public_item_count := jResp.IntOf('public_item_count');
  properties := jResp.StringOf('properties');
  deleted_at := jResp.StringOf('deleted_at');
  fps := jResp.StringOf('fps');
  rating := jResp.StringOf('rating');
  description := jResp.StringOf('description');
  updated_at := jResp.StringOf('updated_at');
  cover_asset_id := jResp.StringOf('cover_asset_id');
  archive_scheduled_at := jResp.StringOf('archive_scheduled_at');
  subtitle_tracks := jResp.StringOf('subtitle_tracks');
  index := jResp.StringOf('index');
  item_count := jResp.IntOf('item_count');
  account_id := jResp.StringOf('account_id');
  name := jResp.StringOf('name');
  checksums := jResp.StringOf('checksums');
  audio_tracks := jResp.StringOf('audio_tracks');
  duration := jResp.StringOf('duration');
  label := jResp.StringOf('label');
  is_session_watermarked := jResp.BoolOf('is_session_watermarked');
  parent_id := jResp.StringOf('parent_id');
  versions := jResp.IntOf('versions');
  project_id := jResp.StringOf('project_id');
  resource_id := jResp.StringOf('resource_id');
  v_private := jResp.BoolOf('private');
  frames := jResp.IntOf('frames');
  autoversion_id := jResp.StringOf('autoversion_id');
  v_type := jResp.StringOf('type');
  uploaded_at := jResp.StringOf('uploaded_at');
  creator_id := jResp.StringOf('creator_id');
  user_permissionsCan_download := jResp.BoolOf('user_permissions.can_download');
  user_permissionsCan_modify_template := jResp.BoolOf('user_permissions.can_modify_template');
  user_permissionsCan_public_share_presentation := jResp.BoolOf('user_permissions.can_public_share_presentation');
  user_permissionsCan_public_share_review_link := jResp.BoolOf('user_permissions.can_public_share_review_link');
  user_permissionsCan_share_downloadable_presentation := jResp.BoolOf('user_permissions.can_share_downloadable_presentation');
  user_permissionsCan_share_downloadable_review_link := jResp.BoolOf('user_permissions.can_share_downloadable_review_link');
  user_permissionsCan_share_unwatermarked_presentation := jResp.BoolOf('user_permissions.can_share_unwatermarked_presentation');
  user_permissionsCan_share_unwatermarked_review_link := jResp.BoolOf('user_permissions.can_share_unwatermarked_review_link');
  shared := jResp.BoolOf('shared');
  is_360 := jResp.BoolOf('is_360');
  v_type := jResp.StringOf('_type');
  comment_count := jResp.IntOf('comment_count');
  archived_at := jResp.StringOf('archived_at');
  filetype := jResp.StringOf('filetype');
  id := jResp.StringOf('id');
  hard_deleted_at := jResp.StringOf('hard_deleted_at');
  copy := jResp.BoolOf('copy');
  is_hls_required := jResp.BoolOf('is_hls_required');
  archive_status := jResp.StringOf('archive_status');
  inserted_at := jResp.StringOf('inserted_at');
  filesize := jResp.IntOf('filesize');


  http.Free;
  json.Free;
  resp.Free;
  sbResponseBody.Free;
  jResp.Free;

end;

// ---------------------------------------------------------------------------

begin

  try
    RunDemo;
  except
    on E: Exception do
      WriteLn('Unhandled exception: ', E.ClassName, ': ', E.Message);
  end;

  WriteLn;
  {$IFDEF MSWINDOWS}
  WriteLn('Press Enter to exit...');
  ReadLn;
  {$ENDIF}
end.