Not able to delete multiple blobs with Blob Batch API

Tanishka Arora 6 Reputation points
2021-09-02T19:06:21.173+00:00

I am trying to delete multiple blobs from a container that is I am using the Blob Batch REST API feature of Azure Blob Storage through Salesforce. For the POST request, I am getting a 202 Status Code but for the subrequest, I am getting a 400 status code stating "One of the Request inputs is not valid". I need help to resolve this issue.

Below is the 128768-screenshot-2021-09-03-003423.pngcode snippet and the error I am facing.

@AuraEnabled
public static void deleteMultipleBlobs(String batchVal){
getCustomMetadataValues();
List<accessTokenWrapper> minutesValue = accessToken();
Http h = new Http();
HttpRequest req= new HttpRequest();
String url = 'https://advance.blob.core.windows.net/?comp=batch';
String setDate = formatDateGMT(); //Tue, 31 Aug 2021 17:54:42 GMT
String boundary = 'batch_'+batchVal;
String delimiter = '\r\n--' + boundary + '\r\n';
String closeDelim = '\r\n--' + boundary + '--';
String body = delimiter+'Content-Type: application/http\r\nContent-Transfer-Encoding: binary\r\nContent-ID: 0\r\n\r\nDELETE /newcontainer02/testblob \r\nx-ms-date: '+setDate+'\r\nAuthorization: Bearer '+minutesValue[0].token+'\r\nContent-Length: 0\r\n'+closeDelim;
system.debug('body--->'+body);
req.setEndpoint(url);
req.setMethod('POST');
req.setHeader('Authorization', 'Bearer '+ minutesValue[0].token);
req.setHeader('x-ms-version', '2018-11-09');
req.setHeader('x-ms-date', setDate);
req.setHeader('Content-Length','221');
req.setHeader('Content-Type','multipart/mixed; boundary=batch_'+batchVal);
req.setbody(body);
HttpResponse res = h.send(req);
system.debug('response of delete Multiple blobs--->'+res.getStatusCode());
system.debug('getResponse body--->'+res.getBody());
}

Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,449 questions
Azure Batch
Azure Batch
An Azure service that provides cloud-scale job scheduling and compute management.
307 questions
{count} votes

1 answer

Sort by: Most helpful
  1. deherman-MSFT 33,701 Reputation points Microsoft Employee
    2021-09-03T20:46:26.11+00:00

    @Tanishka Arora
    I have sent your a private message so that we can work with you more closely on this issue.

    0 comments No comments