Request URL:
/api/Test/Retrieve/14012638/?14012647
Endpoint:
[Route("Retrieve/{firstid}/{secondid?}")]
public async Task<TestAPI> Retrieve(long firstid, long secondid)
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.