I have a POST endpoint that takes a URL path param and then the body is a list of submitted DTOs.
So right now the request DTO looks something along the lines of:
[Route("/prefix/{Param1}", "POST")]
public class SomeRequest
{
public string Param1 { get; set; }
public List<SomeEntry> Entries { get; set; }
}
public class SomeEntry
{
public int ID { get; set; }
public int Type { get; set; }
public string Value { get; set; }
}
And the service method looks something like:
public class SomeService : Service
{
public SomeResponse Post(SomeRequest request)
{
}
}
If encoded via JSON, the client would have to encode the POST body this way:
{
"Entries":
[
{
"id": 1
"type": 42
"value": "Y"
},
...
]
}
This is redundant, I would like the client to submit the data like this:
[
{
"id": 1
"type": 42
"value": "Y"
},
...
]
Which would have been the case if my request DTO was simply List<SomeEntry>
My questions is: is there a way to "flatten" the request this way? Or designate one property of the request as the root of the message body? i.e perhaps:
[Route("/prefix/{Param1}", "POST")]
public class SomeRequest
{
public string Param1 { get; set; }
[MessageBody]
public List<SomeEntry> Entries { get; set; }
}
Is this doable in any way in ServiceStack?