OriginalRequest for Posted requests

I have a service that passes requests to another library (DNOA in this case). That library processes the request in a method that takes the HttpRequestBase.

So on the server, in our service, we are passing the library method the request like this:

DnoaLibrary.SomeMethod((HttpRequestBase)request.OriginalRequest)

From our client, we are POSTing a request DTO like this:

var client = new JsonServiceClient("baseurl");
client.Post(new RequestDto{
    FieldA = "foo",
    FieldB = "bar",
});

The problem seems to be that the DnoaLibrary.SomeMethod() does not find the values of ‘FieldA’ and ‘FieldB’ in the Request.Form["FieldA"] and Request.Form["FieldB"] (nor in the respective QueryString) and so the DnoaLibrary method fails.

I wanted to know how to make this work in our service. (in other words how best to map my request DTO to Form fields in the request.OriginalRequest?)

The JsonServiceClient as the name suggests only POST’s application/json Content Type. In order to be accessible via Request.Form the Request Body needs to be posted as key/value pairs using the application/x-www-form-urlencoded Content-Type which you can’t be done with any of the Service Clients which only send their Content Type.

You can POST Form Data by using HTTP Utils, e.g:

baseUrl.CombineWith("path/info").PostToUrl(new RequestDto {
    FieldA = "foo",
    FieldB = "bar",
});

OK, so I guess I am looking at writing some server side code to convert a JSON DTO to Form data.
Was hoping there was some SS code that could help me do that.

DTOs are not JSON-specific and the code I posted shows how you can use ServiceStack library to POST FormData using a DTO. Don’t see what else is missing.

Nothing missing.
It’s probably not a common case to implement for most SS developers.

My need is to send the data from client to the service as JSON, but then the service needs to convert the JSON request to “application/x-www-form-urlencoded” data so that DNOA can handle the request correctly.