简体   繁体   English

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

[英]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.

相关问题 在 WebAPI 和 AngularJS 中出现错误:“未找到与请求 URI 匹配的 HTTP 资源” - Getting the error: “No HTTP resource was found that matches the request URI” in WebAPI and AngularJS 获取没有与请求URI匹配的HTTP资源 - Getting No HTTP resource was found that matches the request URI 路由错误:找不到与请求URI匹配的HTTP资源 - Routing error: No HTTP resource was found that matches the request URI Web Api错误:“找不到与请求URI匹配的HTTP资源” - Web Api Error: “No HTTP resource was found that matches the request URI” 未找到与请求 URI 匹配的 HTTP 资源,我需要解决方案 - No HTTP resource was found that matches the request URI, I need solutions 未找到与Angular 2中的请求URI匹配的HTTP资源 - No HTTP resource was found that matches the request URI in Angular 2 找不到与请求URI&#39;MyUrl&#39;匹配的HTTP资源 - No HTTP resource was found that matches the request URI 'MyUrl' 找不到与请求URI匹配的HTTP资源 - No HTTP resource was found that matches the request URI 找不到与webapi中的请求URI匹配的HTTP资源 - No HTTP resource was found that matches the request URI in webapi 未找到与请求URI匹配的HTTP资源,未找到与控制器匹配的类型 - No HTTP resource was found that matches the request URI, No type was found that matches the controller
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM