Gets information about Google Drive import formats and export formats.
load ./chilkat.dll
set rest [new_CkRest]
# Provide a previously obtained OAuth2 access token.
set oauth2 [new_CkOAuth2]
CkOAuth2_put_AccessToken $oauth2 "OAUTH2_ACCESS_TOKEN"
CkRest_SetAuthOAuth2 $rest $oauth2
set success [CkRest_Connect $rest "www.googleapis.com" 443 1 1]
if {[expr $success != 1]} then {
puts [CkRest_lastErrorText $rest]
delete_CkRest $rest
delete_CkOAuth2 $oauth2
exit
}
CkRest_AddQueryParam $rest "fields" "importFormats,exportFormats"
set sbJson [new_CkStringBuilder]
set success [CkRest_FullRequestNoBodySb $rest "GET" "/drive/v3/about" $sbJson]
if {[expr $success != 1]} then {
puts [CkRest_lastErrorText $rest]
delete_CkRest $rest
delete_CkOAuth2 $oauth2
delete_CkStringBuilder $sbJson
exit
}
if {[expr [CkRest_ResponseStatusCode $rest] != 200]} then {
puts "Received error response code: [CkRest_ResponseStatusCode $rest]"
puts "Response body:"
puts [CkStringBuilder_getAsString $sbJson]
delete_CkRest $rest
delete_CkOAuth2 $oauth2
delete_CkStringBuilder $sbJson
exit
}
set json [new_CkJsonObject]
CkJsonObject_LoadSb $json $sbJson
# The following code parses the JSON response.
# A sample JSON response is shown below the sample code.
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.text/tab-separated-values"]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.text/tab-separated-values[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.\"application/x-vnd.oasis.opendocument.presentation\""]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.\"application/x-vnd.oasis.opendocument.presentation\"[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.image/jpeg"]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.image/jpeg[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.image/bmp"]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.image/bmp[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.image/gif"]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.image/gif[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.\"application/vnd.ms-excel.sheet.macroenabled.12\""]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.\"application/vnd.ms-excel.sheet.macroenabled.12\"[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.\"application/vnd.openxmlformats-officedocument.wordprocessingml.template\""]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.\"application/vnd.openxmlformats-officedocument.wordprocessingml.template\"[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.\"application/vnd.ms-powerpoint.presentation.macroenabled.12\""]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.\"application/vnd.ms-powerpoint.presentation.macroenabled.12\"[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.\"application/vnd.ms-word.template.macroenabled.12\""]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.\"application/vnd.ms-word.template.macroenabled.12\"[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.\"application/vnd.openxmlformats-officedocument.wordprocessingml.document\""]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.\"application/vnd.openxmlformats-officedocument.wordprocessingml.document\"[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.image/pjpeg"]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.image/pjpeg[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.\"application/vnd.google-apps.script+text/plain\""]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.\"application/vnd.google-apps.script+text/plain\"[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.\"application/vnd.ms-excel\""]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.\"application/vnd.ms-excel\"[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.\"application/vnd.sun.xml.writer\""]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.\"application/vnd.sun.xml.writer\"[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.\"application/vnd.ms-word.document.macroenabled.12\""]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.\"application/vnd.ms-word.document.macroenabled.12\"[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.\"application/vnd.ms-powerpoint.slideshow.macroenabled.12\""]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.\"application/vnd.ms-powerpoint.slideshow.macroenabled.12\"[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.text/rtf"]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.text/rtf[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.text/plain"]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.text/plain[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.\"application/vnd.oasis.opendocument.spreadsheet\""]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.\"application/vnd.oasis.opendocument.spreadsheet\"[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.\"application/x-vnd.oasis.opendocument.spreadsheet\""]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.\"application/x-vnd.oasis.opendocument.spreadsheet\"[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.image/png"]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.image/png[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.\"application/x-vnd.oasis.opendocument.text\""]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.\"application/x-vnd.oasis.opendocument.text\"[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.application/msword"]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.application/msword[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.application/pdf"]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.application/pdf[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.application/json"]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.application/json[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.application/x-msmetafile"]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.application/x-msmetafile[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.\"application/vnd.openxmlformats-officedocument.spreadsheetml.template\""]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.\"application/vnd.openxmlformats-officedocument.spreadsheetml.template\"[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.\"application/vnd.ms-powerpoint\""]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.\"application/vnd.ms-powerpoint\"[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.\"application/vnd.ms-excel.template.macroenabled.12\""]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.\"application/vnd.ms-excel.template.macroenabled.12\"[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.image/x-bmp"]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.image/x-bmp[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.application/rtf"]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.application/rtf[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.\"application/vnd.openxmlformats-officedocument.presentationml.template\""]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.\"application/vnd.openxmlformats-officedocument.presentationml.template\"[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.image/x-png"]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.image/x-png[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.text/html"]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.text/html[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.\"application/vnd.oasis.opendocument.text\""]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.\"application/vnd.oasis.opendocument.text\"[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.\"application/vnd.openxmlformats-officedocument.presentationml.presentation\""]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.\"application/vnd.openxmlformats-officedocument.presentationml.presentation\"[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.\"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\""]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.\"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\"[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.\"application/vnd.google-apps.script+json\""]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.\"application/vnd.google-apps.script+json\"[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.\"application/vnd.openxmlformats-officedocument.presentationml.slideshow\""]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.\"application/vnd.openxmlformats-officedocument.presentationml.slideshow\"[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.\"application/vnd.ms-powerpoint.template.macroenabled.12\""]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.\"application/vnd.ms-powerpoint.template.macroenabled.12\"[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.text/csv"]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.text/csv[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.\"application/vnd.oasis.opendocument.presentation\""]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.\"application/vnd.oasis.opendocument.presentation\"[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.image/jpg"]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.image/jpg[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "importFormats.text/richtext"]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "importFormats.text/richtext[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "exportFormats.\"application/vnd.google-apps.form\""]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "exportFormats.\"application/vnd.google-apps.form\"[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "exportFormats.\"application/vnd.google-apps.document\""]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "exportFormats.\"application/vnd.google-apps.document\"[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "exportFormats.\"application/vnd.google-apps.drawing\""]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "exportFormats.\"application/vnd.google-apps.drawing\"[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "exportFormats.\"application/vnd.google-apps.spreadsheet\""]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "exportFormats.\"application/vnd.google-apps.spreadsheet\"[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "exportFormats.\"application/vnd.google-apps.script\""]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "exportFormats.\"application/vnd.google-apps.script\"[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "exportFormats.\"application/vnd.google-apps.presentation\""]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "exportFormats.\"application/vnd.google-apps.presentation\"[i]"]
set i [expr $i + 1]
}
puts "Example Completed."
delete_CkRest $rest
delete_CkOAuth2 $oauth2
delete_CkStringBuilder $sbJson
delete_CkJsonObject $json
{
"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"
]
}
}