简体   繁体   中英

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

Request 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.

For your requirement, you can do this like below. I assume you are doing a GET operation.

[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:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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