Head Request: RequestDto not populated with query param if default route

Given the following RequestDTO:

public class HeadSample : IReturnVoid
{
    public string Id { get; set; }
}

http HEAD http://localhost/api/json/reply/HeadSample?id=196-A -> Id Property is not pouplated
http HEAD http://localhost/api/head-sample?id=196-A -> Id Property is populated

I expect both scenarios to be the same.

this was already mentioned once on stackoverflow: https://stackoverflow.com/questions/23198379/servicestack-head-request-with-query-parameter-not-working

seems to be a bug in my eyes.

tobi

Are you sure it’s not the other way around, this request:

http://localhost/api/head-sample?id=196-A 

Does not match this route:

[Route("/head-sample/{Id}", "HEAD")]
public class HeadSample : IReturnVoid
{
    public string Id { get; set; }
}

Which requires the Id in the path-info as specified in the route:

http://localhost/api/head-sample/196-A

oh i wrote it in the wrong way, 2nd chance:

Id property not puplated:
http HEAD http://localhost/api/json/reply/HeadSample?id=196-A

Id property is populated:
http HEAD http://localhost/api/head-sample/196-A

The problem is that the typescript client is using the default routes /json/reply/{DtoName} which then ends in an empty request dto on server side.

My expectation:
while using the default route, SS should find the dto/service impl and map the values from body/path/query-string automatically.

This already works for GET/POST with different behaviors depending on the HTTP verb:
GET parameters are passed by query params, POST is using the HTTP body.

My expectation would be that HEAD behaves similar as GET.

Should be resolved from this commit.

This change is available from the latest v5.5.1 that’s now available on MyGet.

thank you again demis!

1 Like

any reasons why HEAD is missing in default methods in CorsFeature.cs?

Don’t recall why it wasn’t included, but it’s just a default which can be changed. I’ve also added it to DefaultMethods in this commit.

This change is available from the latest v5.5.1 on MyGet.

yeah we did override it already.

just thought that it make sense to add, otherwise it feels like a little trap :wink:

thank you!

1 Like