SendAll() how to POST vs. GET

Looking at the auto-batching docs How does the client know which VERB I am wanting to batch up? For example, in one use case, I want to POST the arrays of requests, in another, I want to GET the array of requests.

Physically Auto Batching is only sent over HTTP POST (so calls Post() or Any() Services by default) but you can call a Get() service by overriding the HTTP Verb with a HTTP Header:

I’m getting a “Bad Request” using the following Extension Method. I’m trying to batch GET requests. Any ideas?

public static List<TResponse> SendAll<TResponse>(this JsonServiceClient serviceClient, HttpMethod httpMethod, IEnumerable<IReturn<TResponse>> requests)
{
    try
    {
        serviceClient.RequestFilter = request => request.Headers[HttpHeaders.XHttpMethodOverride] = httpMethod.ToString();
        var sendAll = serviceClient.SendAll(requests);
        return sendAll;
    }
    finally
    {
       serviceClient.RequestFilter = null;
    }
}

I’m using the following TEST and I’m able to get the single Get back successfully, but the SendAll throws a Bad Request

[Test]
public void Can_SendAll_GET()
{
    var requests = new List<PingRequest>();
    requests.Add(new PingRequest());
    requests.Add(new PingRequest());
    requests.Add(new PingRequest());
    requests.Add(new PingRequest());
    requests.Add(new PingRequest());
    // Works
    var response = ServiceClients.UserProfileService.Get(requests.First());
    // Bad Request
    var responses = ServiceClients.UserProfileService.SendAll(HttpMethod.Get, requests); 
 }

Can’t identify issues without seeing any Error Info.

Please post the raw HTTP Request/Response Headers using something like Fiddler or WireShark.

Here is the GET

GET https://dev.io/user-profile-api/system/ping HTTP/1.1
Connection: Keep-Alive
Accept: application/json
User-Agent: ServiceStack .NET Client 5.11
Host: dev.io


HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Content-Length: 55
Connection: keep-alive
Date: Wed, 02 May 2018 06:10:32 GMT
x-amzn-RequestId: 85417a4a-4dcf-11e8-97b2-d7db3a4fe988
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: *
Set-Cookie: ss-id=LfYGYzsXnnQRylIMaHtc; path=/; samesite=lax; httponly,ss-pid=BDvopRAPnkeDoT45GXHj; 
expires=Sun, 02 May 2038 06:10:32 GMT; path=/; samesite=lax; httponly
x-amz-apigw-id: GPpt0FqSCYcF09w=
Vary: Accept
X-Powered-By: ServiceStack/5.11 NETStandard/.NET
Access-Control-Allow-Methods: *
X-Amzn-Trace-Id: sampled=0;root=1-5ae95658-b382308c8efe8439de926e50
Access-Control-Allow-Credentials: true
X-Cache: Miss from cloudfront
Via: 1.1 6ac65de939573cb26099f6407fa8e169.cloudfront.net (CloudFront)
X-Amz-Cf-Id: Qor9YwCutNrevFP_dF77-jMcJq5CP4Uxlzrus5F32TwamhjJjq4vNg==

The “GET” batch is trying to post

POST https://dev.io/user-profile-api/json/reply/PingRequest[] HTTP/1.1
Connection: Keep-Alive
Content-Type: application/json
Accept: application/json
Cookie: ss-id=LfYGYzsXnnQRylIMaHtc; ss-pid=BDvopRAPnkeDoT45GXHj
User-Agent: ServiceStack .NET Client 5.11
X-Http-Method-Override: GET
Content-Length: 16
Host: dev.io


HTTP/1.1 400 Bad Request
Content-Length: 0
Connection: keep-alive
Date: Wed, 02 May 2018 06:10:32 GMT
X-Cache: Error from cloudfront
Via: 1.1 221819fbf7724b735246ce8b6af9132f.cloudfront.net (CloudFront)
X-Amz-Cf-Id: TP3xJBv-C9QL757G_vG0yOypheY0aa-keYoIGWmh3cL6IvLpknADfw==

Like I said all Auto Batched Requests are sent as HTTP POST’s, the XHttpMethodOverride Let’s you call a Get(Request) Service instead of a Post(Request) or Any(Request) Service.

This error didn’t come from ServiceStack, it looks like CloudFront returned the Bad Request Response before the Request was able to reach ServiceStack.