Delphi DLL Google Drive: About: Get Import and Export Formats

Back to Index

Gets information about Google Drive import formats and export formats.

Documentation: https://developers.google.com/drive/v3/reference/about/get


var
rest: HCkRest;
success: Boolean;
oauth2: HCkOAuth2;
sbJson: HCkStringBuilder;
json: HCkJsonObject;
i: Integer;
count_i: Integer;
strVal: PWideChar;

begin
rest := CkRest_Create();

//   Provide a previously obtained OAuth2 access token.
oauth2 := CkOAuth2_Create();
CkOAuth2_putAccessToken(oauth2,'OAUTH2_ACCESS_TOKEN');
CkRest_SetAuthOAuth2(rest,oauth2);

success := CkRest_Connect(rest,'www.googleapis.com',443,True,True);
if (success <> True) then
  begin
    Memo1.Lines.Add(CkRest__lastErrorText(rest));
    Exit;
  end;

CkRest_AddQueryParam(rest,'fields','importFormats,exportFormats');

sbJson := CkStringBuilder_Create();
success := CkRest_FullRequestNoBodySb(rest,'GET','/drive/v3/about',sbJson);
if (success <> True) then
  begin
    Memo1.Lines.Add(CkRest__lastErrorText(rest));
    Exit;
  end;

if (CkRest_getResponseStatusCode(rest) <> 200) then
  begin
    Memo1.Lines.Add('Received error response code: ' + IntToStr(CkRest_getResponseStatusCode(rest)));
    Memo1.Lines.Add('Response body:');
    Memo1.Lines.Add(CkStringBuilder__getAsString(sbJson));
    Exit;
  end;

json := CkJsonObject_Create();
CkJsonObject_LoadSb(json,sbJson);

//  The following code parses the JSON response.
//  A sample JSON response is shown below the sample code.

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats.text/tab-separated-values');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats.text/tab-separated-values[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats."application/x-vnd.oasis.opendocument.presentation"');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats."application/x-vnd.oasis.opendocument.presentation"[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats.image/jpeg');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats.image/jpeg[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats.image/bmp');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats.image/bmp[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats.image/gif');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats.image/gif[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats."application/vnd.ms-excel.sheet.macroenabled.12"');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats."application/vnd.ms-excel.sheet.macroenabled.12"[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats."application/vnd.openxmlformats-officedocument.wordprocessingml.template"');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats."application/vnd.openxmlformats-officedocument.wordprocessingml.template"[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats."application/vnd.ms-powerpoint.presentation.macroenabled.12"');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats."application/vnd.ms-powerpoint.presentation.macroenabled.12"[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats."application/vnd.ms-word.template.macroenabled.12"');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats."application/vnd.ms-word.template.macroenabled.12"[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats."application/vnd.openxmlformats-officedocument.wordprocessingml.document"');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats."application/vnd.openxmlformats-officedocument.wordprocessingml.document"[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats.image/pjpeg');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats.image/pjpeg[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats."application/vnd.google-apps.script+text/plain"');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats."application/vnd.google-apps.script+text/plain"[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats."application/vnd.ms-excel"');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats."application/vnd.ms-excel"[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats."application/vnd.sun.xml.writer"');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats."application/vnd.sun.xml.writer"[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats."application/vnd.ms-word.document.macroenabled.12"');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats."application/vnd.ms-word.document.macroenabled.12"[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats."application/vnd.ms-powerpoint.slideshow.macroenabled.12"');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats."application/vnd.ms-powerpoint.slideshow.macroenabled.12"[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats.text/rtf');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats.text/rtf[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats.text/plain');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats.text/plain[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats."application/vnd.oasis.opendocument.spreadsheet"');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats."application/vnd.oasis.opendocument.spreadsheet"[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats."application/x-vnd.oasis.opendocument.spreadsheet"');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats."application/x-vnd.oasis.opendocument.spreadsheet"[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats.image/png');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats.image/png[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats."application/x-vnd.oasis.opendocument.text"');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats."application/x-vnd.oasis.opendocument.text"[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats.application/msword');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats.application/msword[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats.application/pdf');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats.application/pdf[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats.application/json');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats.application/json[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats.application/x-msmetafile');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats.application/x-msmetafile[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats."application/vnd.openxmlformats-officedocument.spreadsheetml.template"');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats."application/vnd.openxmlformats-officedocument.spreadsheetml.template"[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats."application/vnd.ms-powerpoint"');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats."application/vnd.ms-powerpoint"[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats."application/vnd.ms-excel.template.macroenabled.12"');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats."application/vnd.ms-excel.template.macroenabled.12"[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats.image/x-bmp');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats.image/x-bmp[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats.application/rtf');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats.application/rtf[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats."application/vnd.openxmlformats-officedocument.presentationml.template"');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats."application/vnd.openxmlformats-officedocument.presentationml.template"[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats.image/x-png');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats.image/x-png[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats.text/html');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats.text/html[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats."application/vnd.oasis.opendocument.text"');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats."application/vnd.oasis.opendocument.text"[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats."application/vnd.openxmlformats-officedocument.presentationml.presentation"');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats."application/vnd.openxmlformats-officedocument.presentationml.presentation"[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats."application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats."application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats."application/vnd.google-apps.script+json"');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats."application/vnd.google-apps.script+json"[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats."application/vnd.openxmlformats-officedocument.presentationml.slideshow"');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats."application/vnd.openxmlformats-officedocument.presentationml.slideshow"[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats."application/vnd.ms-powerpoint.template.macroenabled.12"');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats."application/vnd.ms-powerpoint.template.macroenabled.12"[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats.text/csv');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats.text/csv[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats."application/vnd.oasis.opendocument.presentation"');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats."application/vnd.oasis.opendocument.presentation"[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats.image/jpg');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats.image/jpg[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'importFormats.text/richtext');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'importFormats.text/richtext[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'exportFormats."application/vnd.google-apps.form"');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'exportFormats."application/vnd.google-apps.form"[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'exportFormats."application/vnd.google-apps.document"');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'exportFormats."application/vnd.google-apps.document"[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'exportFormats."application/vnd.google-apps.drawing"');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'exportFormats."application/vnd.google-apps.drawing"[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'exportFormats."application/vnd.google-apps.spreadsheet"');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'exportFormats."application/vnd.google-apps.spreadsheet"[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'exportFormats."application/vnd.google-apps.script"');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'exportFormats."application/vnd.google-apps.script"[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(json,'exportFormats."application/vnd.google-apps.presentation"');
while i < count_i do
  begin
CkJsonObject_putI(json,i);
    strVal := CkJsonObject__stringOf(json,'exportFormats."application/vnd.google-apps.presentation"[i]');
    i := i + 1;
  end;

Memo1.Lines.Add('Example Completed.');

CkRest_Dispose(rest);
CkOAuth2_Dispose(oauth2);
CkStringBuilder_Dispose(sbJson);
CkJsonObject_Dispose(json);

Sample JSON Response Body

{
  "importFormats": {
    "text/tab-separated-values": [
      "application/vnd.google-apps.spreadsheet"
    ],
    "application/x-vnd.oasis.opendocument.presentation": [
      "application/vnd.google-apps.presentation"
    ],
    "image/jpeg": [
      "application/vnd.google-apps.document"
    ],
    "image/bmp": [
      "application/vnd.google-apps.document"
    ],
    "image/gif": [
      "application/vnd.google-apps.document"
    ],
    "application/vnd.ms-excel.sheet.macroenabled.12": [
      "application/vnd.google-apps.spreadsheet"
    ],
    "application/vnd.openxmlformats-officedocument.wordprocessingml.template": [
      "application/vnd.google-apps.document"
    ],
    "application/vnd.ms-powerpoint.presentation.macroenabled.12": [
      "application/vnd.google-apps.presentation"
    ],
    "application/vnd.ms-word.template.macroenabled.12": [
      "application/vnd.google-apps.document"
    ],
    "application/vnd.openxmlformats-officedocument.wordprocessingml.document": [
      "application/vnd.google-apps.document"
    ],
    "image/pjpeg": [
      "application/vnd.google-apps.document"
    ],
    "application/vnd.google-apps.script+text/plain": [
      "application/vnd.google-apps.script"
    ],
    "application/vnd.ms-excel": [
      "application/vnd.google-apps.spreadsheet"
    ],
    "application/vnd.sun.xml.writer": [
      "application/vnd.google-apps.document"
    ],
    "application/vnd.ms-word.document.macroenabled.12": [
      "application/vnd.google-apps.document"
    ],
    "application/vnd.ms-powerpoint.slideshow.macroenabled.12": [
      "application/vnd.google-apps.presentation"
    ],
    "text/rtf": [
      "application/vnd.google-apps.document"
    ],
    "text/plain": [
      "application/vnd.google-apps.document"
    ],
    "application/vnd.oasis.opendocument.spreadsheet": [
      "application/vnd.google-apps.spreadsheet"
    ],
    "application/x-vnd.oasis.opendocument.spreadsheet": [
      "application/vnd.google-apps.spreadsheet"
    ],
    "image/png": [
      "application/vnd.google-apps.document"
    ],
    "application/x-vnd.oasis.opendocument.text": [
      "application/vnd.google-apps.document"
    ],
    "application/msword": [
      "application/vnd.google-apps.document"
    ],
    "application/pdf": [
      "application/vnd.google-apps.document"
    ],
    "application/json": [
      "application/vnd.google-apps.script"
    ],
    "application/x-msmetafile": [
      "application/vnd.google-apps.drawing"
    ],
    "application/vnd.openxmlformats-officedocument.spreadsheetml.template": [
      "application/vnd.google-apps.spreadsheet"
    ],
    "application/vnd.ms-powerpoint": [
      "application/vnd.google-apps.presentation"
    ],
    "application/vnd.ms-excel.template.macroenabled.12": [
      "application/vnd.google-apps.spreadsheet"
    ],
    "image/x-bmp": [
      "application/vnd.google-apps.document"
    ],
    "application/rtf": [
      "application/vnd.google-apps.document"
    ],
    "application/vnd.openxmlformats-officedocument.presentationml.template": [
      "application/vnd.google-apps.presentation"
    ],
    "image/x-png": [
      "application/vnd.google-apps.document"
    ],
    "text/html": [
      "application/vnd.google-apps.document"
    ],
    "application/vnd.oasis.opendocument.text": [
      "application/vnd.google-apps.document"
    ],
    "application/vnd.openxmlformats-officedocument.presentationml.presentation": [
      "application/vnd.google-apps.presentation"
    ],
    "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [
      "application/vnd.google-apps.spreadsheet"
    ],
    "application/vnd.google-apps.script+json": [
      "application/vnd.google-apps.script"
    ],
    "application/vnd.openxmlformats-officedocument.presentationml.slideshow": [
      "application/vnd.google-apps.presentation"
    ],
    "application/vnd.ms-powerpoint.template.macroenabled.12": [
      "application/vnd.google-apps.presentation"
    ],
    "text/csv": [
      "application/vnd.google-apps.spreadsheet"
    ],
    "application/vnd.oasis.opendocument.presentation": [
      "application/vnd.google-apps.presentation"
    ],
    "image/jpg": [
      "application/vnd.google-apps.document"
    ],
    "text/richtext": [
      "application/vnd.google-apps.document"
    ]
  },
  "exportFormats": {
    "application/vnd.google-apps.form": [
      "application/zip"
    ],
    "application/vnd.google-apps.document": [
      "application/rtf",
      "application/vnd.oasis.opendocument.text",
      "text/html",
      "application/pdf",
      "application/epub+zip",
      "application/zip",
      "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
      "text/plain"
    ],
    "application/vnd.google-apps.drawing": [
      "image/svg+xml",
      "image/png",
      "application/pdf",
      "image/jpeg"
    ],
    "application/vnd.google-apps.spreadsheet": [
      "application/x-vnd.oasis.opendocument.spreadsheet",
      "text/tab-separated-values",
      "application/pdf",
      "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
      "text/csv",
      "application/zip",
      "application/vnd.oasis.opendocument.spreadsheet"
    ],
    "application/vnd.google-apps.script": [
      "application/vnd.google-apps.script+json"
    ],
    "application/vnd.google-apps.presentation": [
      "application/vnd.oasis.opendocument.presentation",
      "application/pdf",
      "application/vnd.openxmlformats-officedocument.presentationml.presentation",
      "text/plain"
    ]
  }
}