VB.NET UWP/WinRT 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"

VB.NET UWP/WinRT Example

Dim rest As New Chilkat.Rest
Dim success As Boolean

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


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

Dim sbResponseBody As New Chilkat.StringBuilder
success = Await rest.FullRequestNoBodySbAsync("DELETE","/storage/v1/b/chilkat-test-bucket?project=MY_CLOUD_STORAGE_PROJECT",sbResponseBody)
If (success <> True) Then
    Debug.WriteLine(rest.LastErrorText)
    Exit Sub
End If

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