'HttpDeleteAttribute decorator, valid template? C#

Is the next template route valid?

[HttpDelete("withdrawal/client/{clientId}/dni/{dni}?catalogNumber={catalogNumber}&warehouse={warehouseId}")]

I receive an exception, with the next description:

RoutePatternException: The literal section '?catalogNumber=' is invalid. Literal sections cannot contain the '?' character.

Any help would be nice!



Solution 1:[1]

for url

http://.../withdrawal/client/{clientId}/dni/{dni}?catalogNumber={catalogNumber}&warehouse={warehouseId}

your action should be

[HttpDelete("withdrawal/client/{clientId}/dni/{dni}")]
public IActionResult client(int client, string dni, string catalogNumber, string warehouse)
{
  ...
}

or you can make this url

http://../withdrawal/client/{clientId}/dni/{dni}/{catalogNumber?}/{warehouseId?}")]

your action should be

[HttpDelete("withdrawal/client/{clientId}/dni/{dni}/{catalogNumber?}/{warehouseId?}")]
public IActionResult client(int client, string dni, string catalogNumber, string warehouse)
{
  ...
}
````

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Serge