For anyone else that may run into the issue and find this page (as I did), the body has to include a final blank line after the --batch_guid-- line.
Azure Storage Services REST API; Blob Batch; DELETE Operation "One of the request inputs is not valid"
Hi all,
I'm having trouble using the "Blob Batch"-operation of the Blob Service REST API. I tried a lot with the REST Client for VS Code but can't get it to work. Can you help?
I tried out the C# example from here to make sure, that the operation on the account works this way (which it does)
// Get a connection string to our Azure Storage account.
string connectionString = ""BlobEndpoint=https://<myaccount>.blob.core.windows.net/;QueueEndpoint=https://<myaccount>.queue.core.windows.net/;FileEndpoint=https://<myaccount>.file.core.windows.net/;TableEndpoint=https://<myaccount>.table.core.windows.net/;SharedAccessSignature=sv=2019-12-12&ss=bfqt&srt=sco&sp=rwdlacuptfx&se=2022-01-03T18:22:05Z&st=2021-01-02T10:22:05Z&spr=https&sig=z1Sdb7mKy7RWep0bbMFw9omoponD6iosvyrlfwJE%2BwI%3D";";
string containerName = "sample-container";
// Get a reference to a container named "sample-container" and then create it
BlobServiceClient service = new BlobServiceClient(connectionString);
BlobContainerClient container = service.GetBlobContainerClient(containerName);
container.Create();
// Create three blobs named "foo", "bar", and "baz"
BlobClient foo = container.GetBlobClient("foo");
BlobClient bar = container.GetBlobClient("bar");
BlobClient baz = container.GetBlobClient("baz");
foo.Upload(new MemoryStream(Encoding.UTF8.GetBytes("Foo!")));
bar.Upload(new MemoryStream(Encoding.UTF8.GetBytes("Bar!")));
baz.Upload(new MemoryStream(Encoding.UTF8.GetBytes("Baz!")));
// Delete all three blobs at once
BlobBatchClient batch = service.GetBlobBatchClient();
batch.DeleteBlobs(new Uri[] { foo.Uri, bar.Uri, baz.Uri });
I then captured the request with Fiddler Everywhere, which returned something like this
POST https://<myaccount>.blob.core.windows.net/?sv=2019-12-12&ss=bfqt&srt=sco&sp=rwdlacuptfx&se=2022-01-03T18:22:05Z&st=2021-01-02T10:22:05Z&spr=https&sig=z1Sdb7mKy7RWep0bbMFw9omoponD6iosvyrlfwJE%2BwI%3D&comp=batch HTTP/1.1
Host: <myaccount>.blob.core.windows.net
x-ms-version: 2020-02-10
x-ms-client-request-id: 04dc79e6-ea49-4f69-96b7-6068834d0c7e
x-ms-return-client-request-id: true
User-Agent: azsdk-net-Storage.Blobs/12.7.0 (.NET Core 3.1.1; Microsoft Windows 10.0.19042)
Content-Length: 1410
Content-Type: multipart/mixed; boundary=batch_275688cb-ff20-5a51-b98b-7eda33c7a8fc
--batch_275688cb-ff20-5a51-b98b-7eda33c7a8fc
Content-Type: application/http
Content-Transfer-Encoding: binary
Content-ID: 0
DELETE /sample-container3/foo?sv=2019-12-12&ss=bfqt&srt=sco&spr=https&st=2021-01-02T10%3A22%3A05Z&se=2022-01-03T18%3A22%3A05Z&sp=rwdlacuptfx&sig=z1Sdb7mKy7RWep0bbMFw9omoponD6iosvyrlfwJE%2BwI%3D HTTP/1.1
x-ms-client-request-id: 146cb67e-6e16-46ef-a870-834ac05d0704
x-ms-return-client-request-id: true
Content-Length: 0
--batch_275688cb-ff20-5a51-b98b-7eda33c7a8fc
Content-Type: application/http
Content-Transfer-Encoding: binary
Content-ID: 1
DELETE /sample-container3/bar?sv=2019-12-12&ss=bfqt&srt=sco&spr=https&st=2021-01-02T10%3A22%3A05Z&se=2022-01-03T18%3A22%3A05Z&sp=rwdlacuptfx&sig=z1Sdb7mKy7RWep0bbMFw9omoponD6iosvyrlfwJE%2BwI%3D HTTP/1.1
x-ms-client-request-id: 37a0af7f-9c84-482e-a70c-1bf1b6ed2a38
x-ms-return-client-request-id: true
Content-Length: 0
--batch_275688cb-ff20-5a51-b98b-7eda33c7a8fc
Content-Type: application/http
Content-Transfer-Encoding: binary
Content-ID: 2
DELETE /sample-container3/baz?sv=2019-12-12&ss=bfqt&srt=sco&spr=https&st=2021-01-02T10%3A22%3A05Z&se=2022-01-03T18%3A22%3A05Z&sp=rwdlacuptfx&sig=z1Sdb7mKy7RWep0bbMFw9omoponD6iosvyrlfwJE%2BwI%3D HTTP/1.1
x-ms-client-request-id: 15bd4ed6-24be-53e2-8071-e18264b1ca30
x-ms-return-client-request-id: true
Content-Length: 0
--batch_275688cb-ff20-5a51-b98b-7eda33c7a8fc--
I then tried to execute basically the same (only with "sample-container3" instead of "sample-container2") within VS Code, but whatever I try, I receive a "HTTP 202 Accepted" as the "main status", but a "HTTP 400 One of the request inputs is not valid." as the batch response:
HTTP/1.1 202 Accepted
Transfer-Encoding: chunked
Content-Type: multipart/mixed; boundary=batchresponse_1a182dda-7a4c-46aa-a9b8-aa8cfb469b16
Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-request-id: 04690b42-801e-003c-6fbf-e16890000000
x-ms-version: 2020-02-10
x-ms-client-request-id: 04dc79e6-ea49-4f69-96b7-6068834d0c7e
Date: Sun, 03 Jan 2021 10:59:37 GMT
Connection: close
--batchresponse_1a182dda-7a4c-46aa-a9b8-aa8cfb469b16
Content-Type: application/http
HTTP/1.1 400 One of the request inputs is not valid.
x-ms-error-code: InvalidInput
x-ms-request-id: 04690b42-801e-003c-6fbf-e16890000000
x-ms-version: 2020-02-10
x-ms-client-request-id: 04dc79e6-ea49-4f69-96b7-6068834d0c7e
Content-Length: 221
Content-Type: application/xml
Server: Windows-Azure-Blob/1.0
<?xml version="1.0" encoding="utf-8"?>
<Error><Code>InvalidInput</Code><Message>One of the request inputs is not valid.
RequestId:04690b42-801e-003c-6fbf-e16890000000
Time:2021-01-03T10:59:38.0731174Z</Message></Error>
--batchresponse_1a182dda-7a4c-46aa-a9b8-aa8cfb469b16--
Any idea what I'm doing wrong? I also already tried it with Shared Key-auth, with only one request in the batch, with different header-combinations... But whatever I try: I get the "202 Accepted" plus the "400 One of the request inputs is not valid".
Thanks in advance for your help!
Cheers
Simon
1 answer
Sort by: Most helpful
-
Chris Franklin 0 Reputation points Microsoft Employee
2024-10-21T13:12:42.4366667+00:00