Unicode C
Unicode C
Frame.io - Create a Folder
See more Frame.io Examples
Create a folder asset as a child to the root_asset_id.Chilkat Unicode C Downloads
#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkHttpResponseW.h>
#include <C_CkStringBuilderW.h>
void ChilkatSample(void)
{
BOOL success;
HCkHttpW http;
HCkJsonObjectW json;
HCkHttpResponseW resp;
HCkStringBuilderW sbResponseBody;
HCkJsonObjectW jResp;
int respStatusCode;
const wchar_t *team_id;
int public_item_count;
const wchar_t *properties;
const wchar_t *deleted_at;
const wchar_t *fps;
const wchar_t *rating;
const wchar_t *description;
const wchar_t *updated_at;
const wchar_t *cover_asset_id;
const wchar_t *archive_scheduled_at;
const wchar_t *subtitle_tracks;
const wchar_t *index;
int item_count;
const wchar_t *account_id;
const wchar_t *name;
const wchar_t *checksums;
const wchar_t *audio_tracks;
const wchar_t *duration;
const wchar_t *label;
BOOL is_session_watermarked;
const wchar_t *parent_id;
int versions;
const wchar_t *project_id;
const wchar_t *resource_id;
BOOL v_private;
int frames;
const wchar_t *autoversion_id;
const wchar_t *v_type;
const wchar_t *uploaded_at;
const wchar_t *creator_id;
BOOL user_permissionsCan_download;
BOOL user_permissionsCan_modify_template;
BOOL user_permissionsCan_public_share_presentation;
BOOL user_permissionsCan_public_share_review_link;
BOOL user_permissionsCan_share_downloadable_presentation;
BOOL user_permissionsCan_share_downloadable_review_link;
BOOL user_permissionsCan_share_unwatermarked_presentation;
BOOL user_permissionsCan_share_unwatermarked_review_link;
BOOL shared;
BOOL is_360;
int comment_count;
const wchar_t *archived_at;
const wchar_t *filetype;
const wchar_t *id;
const wchar_t *hard_deleted_at;
BOOL copy;
BOOL is_hls_required;
const wchar_t *archive_status;
const wchar_t *inserted_at;
int filesize;
success = FALSE;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_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 = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(json,L"type",L"folder");
CkJsonObjectW_UpdateString(json,L"name",L"Folder at root");
CkHttpW_SetRequestHeader(http,L"content-type",L"application/json");
// Adds the "Authorization: Bearer <FRAME_IO_DEV_TOKEN>" header.
CkHttpW_putAuthToken(http,L"<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 = CkHttpResponseW_Create();
success = CkHttpW_HttpJson(http,L"POST",L"https://api.frame.io/v2/assets/4ecb383f-71a8-4233-b665-d8f75136f554/children",json,L"application/json",resp);
if (success == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
CkHttpResponseW_Dispose(resp);
return;
}
sbResponseBody = CkStringBuilderW_Create();
CkHttpResponseW_GetBodySb(resp,sbResponseBody);
jResp = CkJsonObjectW_Create();
CkJsonObjectW_LoadSb(jResp,sbResponseBody);
CkJsonObjectW_putEmitCompact(jResp,FALSE);
wprintf(L"Response Body:\n");
wprintf(L"%s\n",CkJsonObjectW_emit(jResp));
respStatusCode = CkHttpResponseW_getStatusCode(resp);
wprintf(L"Response Status Code = %d\n",respStatusCode);
if (respStatusCode >= 400) {
wprintf(L"Response Header:\n");
wprintf(L"%s\n",CkHttpResponseW_header(resp));
wprintf(L"Failed.\n");
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
CkHttpResponseW_Dispose(resp);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jResp);
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
// Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.
// See this example explaining how this memory should be used: const char * functions.
team_id = CkJsonObjectW_stringOf(jResp,L"team_id");
public_item_count = CkJsonObjectW_IntOf(jResp,L"public_item_count");
properties = CkJsonObjectW_stringOf(jResp,L"properties");
deleted_at = CkJsonObjectW_stringOf(jResp,L"deleted_at");
fps = CkJsonObjectW_stringOf(jResp,L"fps");
rating = CkJsonObjectW_stringOf(jResp,L"rating");
description = CkJsonObjectW_stringOf(jResp,L"description");
updated_at = CkJsonObjectW_stringOf(jResp,L"updated_at");
cover_asset_id = CkJsonObjectW_stringOf(jResp,L"cover_asset_id");
archive_scheduled_at = CkJsonObjectW_stringOf(jResp,L"archive_scheduled_at");
subtitle_tracks = CkJsonObjectW_stringOf(jResp,L"subtitle_tracks");
index = CkJsonObjectW_stringOf(jResp,L"index");
item_count = CkJsonObjectW_IntOf(jResp,L"item_count");
account_id = CkJsonObjectW_stringOf(jResp,L"account_id");
name = CkJsonObjectW_stringOf(jResp,L"name");
checksums = CkJsonObjectW_stringOf(jResp,L"checksums");
audio_tracks = CkJsonObjectW_stringOf(jResp,L"audio_tracks");
duration = CkJsonObjectW_stringOf(jResp,L"duration");
label = CkJsonObjectW_stringOf(jResp,L"label");
is_session_watermarked = CkJsonObjectW_BoolOf(jResp,L"is_session_watermarked");
parent_id = CkJsonObjectW_stringOf(jResp,L"parent_id");
versions = CkJsonObjectW_IntOf(jResp,L"versions");
project_id = CkJsonObjectW_stringOf(jResp,L"project_id");
resource_id = CkJsonObjectW_stringOf(jResp,L"resource_id");
v_private = CkJsonObjectW_BoolOf(jResp,L"private");
frames = CkJsonObjectW_IntOf(jResp,L"frames");
autoversion_id = CkJsonObjectW_stringOf(jResp,L"autoversion_id");
v_type = CkJsonObjectW_stringOf(jResp,L"type");
uploaded_at = CkJsonObjectW_stringOf(jResp,L"uploaded_at");
creator_id = CkJsonObjectW_stringOf(jResp,L"creator_id");
user_permissionsCan_download = CkJsonObjectW_BoolOf(jResp,L"user_permissions.can_download");
user_permissionsCan_modify_template = CkJsonObjectW_BoolOf(jResp,L"user_permissions.can_modify_template");
user_permissionsCan_public_share_presentation = CkJsonObjectW_BoolOf(jResp,L"user_permissions.can_public_share_presentation");
user_permissionsCan_public_share_review_link = CkJsonObjectW_BoolOf(jResp,L"user_permissions.can_public_share_review_link");
user_permissionsCan_share_downloadable_presentation = CkJsonObjectW_BoolOf(jResp,L"user_permissions.can_share_downloadable_presentation");
user_permissionsCan_share_downloadable_review_link = CkJsonObjectW_BoolOf(jResp,L"user_permissions.can_share_downloadable_review_link");
user_permissionsCan_share_unwatermarked_presentation = CkJsonObjectW_BoolOf(jResp,L"user_permissions.can_share_unwatermarked_presentation");
user_permissionsCan_share_unwatermarked_review_link = CkJsonObjectW_BoolOf(jResp,L"user_permissions.can_share_unwatermarked_review_link");
shared = CkJsonObjectW_BoolOf(jResp,L"shared");
is_360 = CkJsonObjectW_BoolOf(jResp,L"is_360");
v_type = CkJsonObjectW_stringOf(jResp,L"_type");
comment_count = CkJsonObjectW_IntOf(jResp,L"comment_count");
archived_at = CkJsonObjectW_stringOf(jResp,L"archived_at");
filetype = CkJsonObjectW_stringOf(jResp,L"filetype");
id = CkJsonObjectW_stringOf(jResp,L"id");
hard_deleted_at = CkJsonObjectW_stringOf(jResp,L"hard_deleted_at");
copy = CkJsonObjectW_BoolOf(jResp,L"copy");
is_hls_required = CkJsonObjectW_BoolOf(jResp,L"is_hls_required");
archive_status = CkJsonObjectW_stringOf(jResp,L"archive_status");
inserted_at = CkJsonObjectW_stringOf(jResp,L"inserted_at");
filesize = CkJsonObjectW_IntOf(jResp,L"filesize");
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
CkHttpResponseW_Dispose(resp);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jResp);
}