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

How do I get the latest version in the v5 line of the x tool?

I assume the x tool version number should match the version number of the ServiceStack packages I’m using in my project?

C:\WINDOWS\system32>dotnet tool install --global x --version 5.5.1
C:\Users\micha\AppData\Local\Temp\44cec048-6832-41df-980b-e979689b573a\restore.csproj : warning NU1603: restore depends
on x (>= 5.5.1) but x 5.5.1 was not found. An approximate best match of x 6.0.0 was resolved.
You can invoke the tool using the following command: x
Tool ‘x’ (version ‘6.0.0’) was successfully installed.

I’m also not getting query string parameters mapped when calling /json/reply/{DtoName}?x=1

Using v5.14 of ServiceStack.

The dotnet tools shouldn’t have any binary dependencies with your project, so they shouldn’t need to match the same version unless you’re using it to launch Desktop Apps using your .dll’s.

All the versions are listed on the NuGet page: NuGet Gallery | x 6.0.12