REST WCF Service - Consume QueryString Parameters
Asked Answered
V

1

1

I have this REST WCF service.

[WebInvoke(UriTemplate = "/GetNames/{Category}?order=asc", Method = "POST", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)] 
public List<Names> GetNames(string Category)
{
    //Code to retrieve Names by category.
}

The Category parameter is mapped to {Category} in the Uri.

But how can I map the order query string in the Uri to this method?

Adding the order as a parameter method is not working.

please help. thanks in advance.

Vastha answered 25/3, 2011 at 11:13 Comment(1)
If you post code, XML or data samples, please highlight those lines in the text editor and click on the "code samples" button ( { } ) on the editor toolbar to nicely format and syntax highlight it! If you post error messages, please use the blockquotes ( ` " ` ) to properly format the error message.Decencies
F
2

Have you tried - "/GetNames/{Category}?order={ordering}" in the Uritemplate and in the function

public List<Names> GetNames(string Category, string ordering)
{
  //Code to retrieve Names by category.
}
Faunie answered 29/3, 2011 at 18:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.