Reputation: 1631
I need to create this URL
for request using ServiceStack
, but I couldn't find a way to generate this as URL
route:
http://server.com/myserver?service=2&item[0].reference=222&item[1].reference=233
Below you can see my attempt:
[Route("myserver", "GET")]
public class Request1: IReturn<string>
{
public int Service { get; set; }
public List<Item> item { get; set;}
}
public class Item
{
public int Reference { get; set; }
}
Upvotes: 2
Views: 357
Reputation: 143409
Firstly you should avoid designing APIs that accept complex types over a queryString like this as it reduces interoperability given every framework that supports sending complex types does it differently.
But it's not clear why you would want to create url like this for a ServiceStack request given ServiceStack expects complex types using the JSV Format which is already built into the C# Service Clients.
I'm assuming you're not trying to send this request to a ServiceStack Service but instead want to send this to a 3rd Party API. ServiceStack's C# Service Clients are opinionated towards communicating with ServiceStack Services, If you want to send requests to 3rd Party APIs I'd instead recommend using HTTP Utils where you're free to create the Request yourself.
But in general if you want to customize how the queryString is generated you can use a custom IUrlFilter.
Upvotes: 2