How to configure Api web route to accept query string?

2

I have a web api with the following method:

 [HttpGet]
 [Route("api/documento/doc/list?{cpf}")]
 public string Listar(string cpf)
 {
      return "value";
 } 

I need the above method to be called through the url:

  

link

The big problem is the "?" between the list and the cpf.

How can I change the route to work with the above URL?

    
asked by anonymous 15.02.2017 / 13:52

1 answer

1

Set the route without the "?", the query string will be mapped automatically to the parameter of the same name.

 [HttpGet]
 [Route("api/documento/doc/list")]
 public string Listar(string cpf)
 {
      return "value";
 } 
    
15.02.2017 / 18:41