繁体   English   中英

我收到错误“没有找到与请求 URI 匹配的 HTTP 资源”

[英]I am getting error “No HTTP resource was found that matches the request URI”

请求 URL:

/api/Test/Retrieve/14012638/?14012647

端点:

[Route("Retrieve/{firstid}/{secondid?}")]       
public async Task<TestAPI> Retrieve(long firstid, long secondid)

最好将您的路线放在 controller 级别,将 HTTP 动词放在操作级别。

根据您的要求,您可以像下面那样执行此操作。 我假设您正在执行GET操作。

[HttpGet("Retrieve/{firstid}/{secondid?}")]    
public async Task<WellsTradeAccountsInformation> Retrieve(long firstid, long secondid) { … }

如果您的控制器的路由是api/Test ,那么您可以将其称为:

GET /api/Test/Retrieve/14012638/14012647

或者

GET /api/Test/Retrieve/14012638

由于第二个参数是可选值类型,如果不传递默认为0。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM