I am trying to get the list of versionIDs of an Azure blob via the Java SDK version 12.10.2 but it only returns the HTTP error 400 with the following error message
com.azure.storage.blob.models.BlobStorageException: Status code 400, "<?xml version="1.0" encoding="utf-8"?><Error><Code>InvalidQueryParameterValue</Code><Message>Value for one of the query parameters specified in the request URI is invalid.
RequestId:bd7e9a20-401e-003e-6d7b-37d0dd000000
Time:2021-04-22T13:29:12.0965760Z</Message><QueryParameterName>include</QueryParameterName><QueryParameterValue>versions</QueryParameterValue><Reason>Invalid query parameter value.</Reason></Error>"
And, this is my Java code:
public static BlobContainerAsyncClient getAzureAsyncClient(String accountName, String accountKey, String endpoint) {
String connectionString = getConnectionString(accountName, accountKey, endpoint);
BlobContainerAsyncClient blobServiceClient = new BlobContainerClientBuilder()
.connectionString(connectionString)
.serviceVersion(version)
.buildAsyncClient();
RWLog.MAIN.info("Azure Storage Async Service Client created for " + accountName);
return blobServiceClient;
}
BlobContainerAsyncClient containerClient = AzureConnection.getAzureAsyncClient(folder.getBucket(), folder.getSecretKey(), folder.getEndpoint());
ListBlobsOptions ops = new ListBlobsOptions();
ops.getDetails().setRetrieveVersions(true);
ops.setPrefix(blobKey);
PagedFlux<BlobItem> list =
containerClient.listBlobsByHierarchy("/", ops);
It looks like the HTTP request constructed by the Java SDK is not recognizable by the Azure blobs server. The server side is not able to process the versions-included query from the Java client. Any thoughts?
Just Try this using 12.10.2 of
azure-storage-blob
to get all versions of a blob:Result: