Sample code for 30+ languages & platforms
VB.NET

Dropbox: Get Space Usage

See more Dropbox Examples

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

Chilkat VB.NET Downloads

VB.NET
Dim success As Boolean = False

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

Dim rest As New Chilkat.Rest

' Connect to the www.dropbox.com endpoint.
Dim bTls As Boolean = True
Dim port As Integer = 443
Dim bAutoReconnect As Boolean = True
success = rest.Connect("api.dropboxapi.com",port,bTls,bAutoReconnect)
If (success <> True) Then
    Debug.WriteLine(rest.LastErrorText)
    Exit Sub
End If


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

Dim responseStr As String = rest.FullRequestNoBody("POST","/2/users/get_space_usage")
If (rest.LastMethodSuccess <> True) Then
    Debug.WriteLine(rest.LastErrorText)
    Exit Sub
End If


' Success is indicated by a 200 response status code.
If (rest.ResponseStatusCode <> 200) Then
    ' Examine the request/response to see what happened.
    Debug.WriteLine("response status code = " & rest.ResponseStatusCode)
    Debug.WriteLine("response status text = " & rest.ResponseStatusText)
    Debug.WriteLine("response header: " & rest.ResponseHeader)
    Debug.WriteLine("response body (if any): " & responseStr)
    Debug.WriteLine("---")
    Debug.WriteLine("LastRequestStartLine: " & rest.LastRequestStartLine)
    Debug.WriteLine("LastRequestHeader: " & rest.LastRequestHeader)
    Exit Sub
End If


Dim jsonResponse As New Chilkat.JsonObject
jsonResponse.Load(responseStr)

jsonResponse.EmitCompact = False
Debug.WriteLine(jsonResponse.Emit())

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