Visual Basic 6.0 Google Cloud Storage: Delete Bucket

Back to Index

Permanently deletes an empty bucket. The path parameter is the name of the bucket to delete. In this example, we are deleting the bucket "chilkat-test-bucket". Success is indicated by a 204 response status code with an empty response body.

Documentation: https://cloud.google.com/storage/docs/json_api/v1/buckets/delete

CURL Command

curl -X DELETE https://www.googleapis.com/storage/v1/b/chilkat-test-bucket?project=MY_CLOUD_STORAGE_PROJECT \
    --header "Authorization: Bearer CLOUD_STORAGE_TOKEN"

Visual Basic 6.0 Example

Dim rest As New ChilkatRest
Dim success As Long

'  URL: https://www.googleapis.com/storage/v1/b/chilkat-test-bucket?project=MY_CLOUD_STORAGE_PROJECT
Dim bTls As Long
bTls = 1
Dim port As Long
port = 443
Dim bAutoReconnect As Long
bAutoReconnect = 1
success = rest.Connect("www.googleapis.com",port,bTls,bAutoReconnect)
If (success <> 1) Then
    Debug.Print "ConnectFailReason: " & rest.ConnectFailReason
    Debug.Print rest.LastErrorText
    Exit Sub
End If

success = rest.AddHeader("Authorization","Bearer CLOUD_STORAGE_TOKEN")

Dim sbResponseBody As New ChilkatStringBuilder
success = rest.FullRequestNoBodySb("DELETE","/storage/v1/b/chilkat-test-bucket?project=MY_CLOUD_STORAGE_PROJECT",sbResponseBody)
If (success <> 1) Then
    Debug.Print rest.LastErrorText
    Exit Sub
End If

Dim respStatusCode As Long
respStatusCode = rest.ResponseStatusCode
If (respStatusCode >= 400) Then
    Debug.Print "Response Status Code = " & respStatusCode
    Debug.Print "Response Header:"
    Debug.Print rest.ResponseHeader
    Debug.Print "Response Body:"
    Debug.Print sbResponseBody.GetAsString()
    Exit Sub
End If