PowerBuilder 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


integer li_rc
oleobject loo_Rest
integer li_Success
oleobject loo_Oauth2
oleobject loo_SbJson
oleobject loo_Json
integer i
integer li_Count_i
string ls_StrVal

loo_Rest = create oleobject
li_rc = loo_Rest.ConnectToNewObject("Chilkat_9_5_0.Rest")
if li_rc < 0 then
    destroy loo_Rest
    MessageBox("Error","Connecting to COM object failed")
    return
end if

//   Provide a previously obtained OAuth2 access token.
loo_Oauth2 = create oleobject
li_rc = loo_Oauth2.ConnectToNewObject("Chilkat_9_5_0.OAuth2")

loo_Oauth2.AccessToken = "OAUTH2_ACCESS_TOKEN"
loo_Rest.SetAuthOAuth2(loo_Oauth2)

li_Success = loo_Rest.Connect("www.googleapis.com",443,1,1)
if li_Success <> 1 then
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
    destroy loo_Oauth2
    return
end if

loo_Rest.AddQueryParam("fields","importFormats,exportFormats")

loo_SbJson = create oleobject
li_rc = loo_SbJson.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

li_Success = loo_Rest.FullRequestNoBodySb("GET","/drive/v3/about",loo_SbJson)
if li_Success <> 1 then
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
    destroy loo_Oauth2
    destroy loo_SbJson
    return
end if

if loo_Rest.ResponseStatusCode <> 200 then
    Write-Debug "Received error response code: " + string(loo_Rest.ResponseStatusCode)
    Write-Debug "Response body:"
    Write-Debug loo_SbJson.GetAsString()
    destroy loo_Rest
    destroy loo_Oauth2
    destroy loo_SbJson
    return
end if

loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_Json.LoadSb(loo_SbJson)

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

i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.text/tab-separated-values")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.text/tab-separated-values[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.\"application/x-vnd.oasis.opendocument.presentation\"")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.\"application/x-vnd.oasis.opendocument.presentation\"[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.image/jpeg")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.image/jpeg[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.image/bmp")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.image/bmp[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.image/gif")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.image/gif[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.\"application/vnd.ms-excel.sheet.macroenabled.12\"")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.\"application/vnd.ms-excel.sheet.macroenabled.12\"[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.\"application/vnd.openxmlformats-officedocument.wordprocessingml.template\"")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.\"application/vnd.openxmlformats-officedocument.wordprocessingml.template\"[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.\"application/vnd.ms-powerpoint.presentation.macroenabled.12\"")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.\"application/vnd.ms-powerpoint.presentation.macroenabled.12\"[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.\"application/vnd.ms-word.template.macroenabled.12\"")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.\"application/vnd.ms-word.template.macroenabled.12\"[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.\"application/vnd.openxmlformats-officedocument.wordprocessingml.document\"")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.\"application/vnd.openxmlformats-officedocument.wordprocessingml.document\"[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.image/pjpeg")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.image/pjpeg[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.\"application/vnd.google-apps.script+text/plain\"")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.\"application/vnd.google-apps.script+text/plain\"[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.\"application/vnd.ms-excel\"")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.\"application/vnd.ms-excel\"[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.\"application/vnd.sun.xml.writer\"")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.\"application/vnd.sun.xml.writer\"[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.\"application/vnd.ms-word.document.macroenabled.12\"")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.\"application/vnd.ms-word.document.macroenabled.12\"[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.\"application/vnd.ms-powerpoint.slideshow.macroenabled.12\"")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.\"application/vnd.ms-powerpoint.slideshow.macroenabled.12\"[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.text/rtf")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.text/rtf[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.text/plain")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.text/plain[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.\"application/vnd.oasis.opendocument.spreadsheet\"")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.\"application/vnd.oasis.opendocument.spreadsheet\"[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.\"application/x-vnd.oasis.opendocument.spreadsheet\"")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.\"application/x-vnd.oasis.opendocument.spreadsheet\"[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.image/png")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.image/png[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.\"application/x-vnd.oasis.opendocument.text\"")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.\"application/x-vnd.oasis.opendocument.text\"[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.application/msword")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.application/msword[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.application/pdf")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.application/pdf[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.application/json")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.application/json[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.application/x-msmetafile")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.application/x-msmetafile[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.\"application/vnd.openxmlformats-officedocument.spreadsheetml.template\"")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.\"application/vnd.openxmlformats-officedocument.spreadsheetml.template\"[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.\"application/vnd.ms-powerpoint\"")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.\"application/vnd.ms-powerpoint\"[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.\"application/vnd.ms-excel.template.macroenabled.12\"")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.\"application/vnd.ms-excel.template.macroenabled.12\"[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.image/x-bmp")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.image/x-bmp[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.application/rtf")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.application/rtf[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.\"application/vnd.openxmlformats-officedocument.presentationml.template\"")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.\"application/vnd.openxmlformats-officedocument.presentationml.template\"[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.image/x-png")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.image/x-png[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.text/html")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.text/html[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.\"application/vnd.oasis.opendocument.text\"")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.\"application/vnd.oasis.opendocument.text\"[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.\"application/vnd.openxmlformats-officedocument.presentationml.presentation\"")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.\"application/vnd.openxmlformats-officedocument.presentationml.presentation\"[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.\"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\"")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.\"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\"[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.\"application/vnd.google-apps.script+json\"")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.\"application/vnd.google-apps.script+json\"[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.\"application/vnd.openxmlformats-officedocument.presentationml.slideshow\"")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.\"application/vnd.openxmlformats-officedocument.presentationml.slideshow\"[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.\"application/vnd.ms-powerpoint.template.macroenabled.12\"")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.\"application/vnd.ms-powerpoint.template.macroenabled.12\"[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.text/csv")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.text/csv[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.\"application/vnd.oasis.opendocument.presentation\"")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.\"application/vnd.oasis.opendocument.presentation\"[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.image/jpg")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.image/jpg[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("importFormats.text/richtext")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("importFormats.text/richtext[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("exportFormats.\"application/vnd.google-apps.form\"")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("exportFormats.\"application/vnd.google-apps.form\"[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("exportFormats.\"application/vnd.google-apps.document\"")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("exportFormats.\"application/vnd.google-apps.document\"[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("exportFormats.\"application/vnd.google-apps.drawing\"")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("exportFormats.\"application/vnd.google-apps.drawing\"[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("exportFormats.\"application/vnd.google-apps.spreadsheet\"")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("exportFormats.\"application/vnd.google-apps.spreadsheet\"[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("exportFormats.\"application/vnd.google-apps.script\"")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("exportFormats.\"application/vnd.google-apps.script\"[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("exportFormats.\"application/vnd.google-apps.presentation\"")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("exportFormats.\"application/vnd.google-apps.presentation\"[i]")
    i = i + 1
loop

Write-Debug "Example Completed."


destroy loo_Rest
destroy loo_Oauth2
destroy loo_SbJson
destroy loo_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"
    ]
  }
}