[英]I am getting error “No HTTP resource was found that matches the request URI”
Request URL:请求 URL:
/api/Test/Retrieve/14012638/?14012647
Endpoint:端点:
[Route("Retrieve/{firstid}/{secondid?}")]
public async Task<TestAPI> Retrieve(long firstid, long secondid)
It is always better to place your route at the controller level and your HTTP verb at the action level.最好将您的路线放在 controller 级别,将 HTTP 动词放在操作级别。
For your requirement, you can do this like below.根据您的要求,您可以像下面那样执行此操作。 I assume you are doing a
GET
operation.我假设您正在执行
GET
操作。
[HttpGet("Retrieve/{firstid}/{secondid?}")]
public async Task<WellsTradeAccountsInformation> Retrieve(long firstid, long secondid) { … }
If your controller' route is api/Test
, then you can call this as:如果您的控制器的路由是
api/Test
,那么您可以将其称为:
GET /api/Test/Retrieve/14012638/14012647
or或者
GET /api/Test/Retrieve/14012638
As the second parameter is an optional value type, if you don't pass it will default to 0.由于第二个参数是可选值类型,如果不传递默认为0。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.