Sample code for 30+ languages & platforms
AutoIt

Dropbox: Get Space Usage

See more Dropbox Examples

Demonstrates how to get the Dropbox space usage information for the current user's account.

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

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

$oRest = ObjCreate("Chilkat.Rest")

; Connect to the www.dropbox.com endpoint.
Local $bTls = True
Local $iPort = 443
Local $bAutoReconnect = True
$bSuccess = $oRest.Connect("api.dropboxapi.com",$iPort,$bTls,$bAutoReconnect)
If ($bSuccess <> True) Then
    ConsoleWrite($oRest.LastErrorText & @CRLF)
    Exit
EndIf

$oRest.AddHeader("Authorization","Bearer DROPBOX-ACCESS-TOKEN")

Local $sResponseStr = $oRest.FullRequestNoBody("POST","/2/users/get_space_usage")
If ($oRest.LastMethodSuccess <> True) Then
    ConsoleWrite($oRest.LastErrorText & @CRLF)
    Exit
EndIf

; Success is indicated by a 200 response status code.
If ($oRest.ResponseStatusCode <> 200) Then
    ; Examine the request/response to see what happened.
    ConsoleWrite("response status code = " & $oRest.ResponseStatusCode & @CRLF)
    ConsoleWrite("response status text = " & $oRest.ResponseStatusText & @CRLF)
    ConsoleWrite("response header: " & $oRest.ResponseHeader & @CRLF)
    ConsoleWrite("response body (if any): " & $sResponseStr & @CRLF)
    ConsoleWrite("---" & @CRLF)
    ConsoleWrite("LastRequestStartLine: " & $oRest.LastRequestStartLine & @CRLF)
    ConsoleWrite("LastRequestHeader: " & $oRest.LastRequestHeader & @CRLF)
    Exit
EndIf

$oJsonResponse = ObjCreate("Chilkat.JsonObject")
$oJsonResponse.Load($sResponseStr)

$oJsonResponse.EmitCompact = False
ConsoleWrite($oJsonResponse.Emit() & @CRLF)

; {
;   "used": 3032115,
;   "allocation": {
;     ".tag": "individual",
;     "allocated": 2147483648
;   }
; }
;