I'm trying to use the new batch REST calls as documented here https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_composite_batch.htm#topic-title

But I get the following;

My request body;


The Response

[{"errorCode":"INVALID_BATCH_SIZE","message":"No requests found in batch request"}]

This was using services/data/v34.0/composite/batch.

Has anyone got a working example of this please?

  • 1
    Make sure you're setting the content-type header correctly (to application/json)
    – superfell
    Jun 17, 2015 at 1:16

3 Answers 3



What you are doing should definitely work. The endpoint you are posting to looks correct, and the payload is in the correct format. I would expect you to receive an error, but the error should be 404s since the account you are using does not exist in your system...not an invalid batch size error.

Would you be able to log a case with support and provide:

  • The specific way you are submitting the request (Workbench, curl, apex, some custom code)
  • Login access granted to your org
  • The org id for the org you are testing on

Once you have done that, respond with the case number and I can take a look on our side.

Thanks in advance. Jay


I would assume that since you are using the ID from the example:


That no records matched that ID and thus the query returns no records.

Simply replace the 001D000000K0fXOIAZ with the ID of an existing account in your org

The following works well when execute from the Dev Console but you need the correct ID

String bdy = '{"batchRequests":[{"method":"PATCH","url":"v34.0/sobjects/account/001A000000bK0KH","richInput":{"Name":"NewName"}},{"method":"GET","url":"v34.0/sobjects/account/001A000000bK0KH?fields=Name,BillingPostalCode"}]}';
HttpRequest req = new HttpRequest();
req.setHeader('content-type', 'application/json');
req.setHeader('Authorization', 'Bearer ' + userinfo.getSessionID());
HttpResponse res = new Http().send(req);
  • That is worth a shot... thanks. My thinking however is that it would still result in response relating to the sub-operation, rather than one referencing the batch request itself. I shall tweak this to reflect a REST call that I first validate works outside of the batch. Jun 16, 2015 at 21:02
  • I have tried with IDs that I know exist and return values, still no joy sadly. Jun 16, 2015 at 21:23

The issue was the Content-Type being set incorrectly... D'oh!

I initially tried my request using curl instead and this worked. Here's the command I used (I have masked my accessToken);

curl https://eu5.salesforce.com/services/data/v34.0/composite/batch \
  -H 'Authorization: Bearer <MY-ACCESS-TOKEN>' \
  -H "Content-Type: application/json" \
  -X POST \

I was using the forcejs library in my original query, and I had mistakenly assumed that the default content-type was json. Once I had set this correctly then my calls went through just fine.

Thanks all for you help.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .