[Route("/api/whatever", "PUT")]
public class Check : IUrlFilter
{
[IgnoreDataMember]
public string Token { get; set; }
public string ToUrl(string absoluteUrl)
{
return Token.IsNullOrEmpty() ? absoluteUrl : absoluteUrl.AddQueryParam("token", Token);
}
}
Is it expected behaviour that new Check().ToUrl() throws the following exception but new Check().ToPutUrl() works correctly?
None of the given rest routes matches ‘Check’ request:
/api/whatever: Allowed HTTP methods ‘PUT’ does not support the specified ‘GET’ method.
[EDIT] I just saw the default verb on ToUrl() is set to “GET” so I guess that is the reason for the error, is there a way to generate the route by relying on the RouteAttribute rather than the passing the verb?
That’s not possible, a Service can have many routes definitions with different verbs and variables/weights, you need to tell it which verb you want at the call-site, reverse routing then picks the most appropriate route based on the verb and populated DTO.
How can I exclude a request type from being returned by the ‘Add ServiceStack Reference’ DTO generation?
I am filtering these using the metadata in a plugin as below using the fact that SS internal types have an ExcludeAttrribute but adding that attribute to my request also isn’t excluding it from generation
Can you open a new question/thread for this please? it’s not covered by the original question and makes it difficult for others to find the answers to.