HttpGet用于访问url



我想从https://api.cqc.org.uk/public/v1/changes/location?page=1&perPage=1000000&startTimestamp=2021-09-18T02:33:20Z&endTimestamp=2021-09-19T02:33:20Z获取信息

我写了下面的代码,但是它似乎不起作用

[HttpGet("changes/location{page}&{perPage}&{startTimestamp}&{endTimestamp}")]
public async Task<ChangesDetailsVM>GetChange([FromRoute] string page, string perPage,  string startTimestamp, string endTimestamp)
{
return await _cqcService.GetChange(page, perPage, startTimestamp, endTimestamp);
}

From Postman我收到了以下错误:

请求cqc/changes/location1&1000&9/20/2021 8:57:53 AM失败,状态码NotFound响应:{"statusCode": 404, "message"; "资源未找到"}">

有什么建议可以改善我的罪过吗?

如果使用路由可以这样写:

// route
[HttpGet("changes/location/{page}/{perPage}/{startTimestamp}/{endTimestamp}")]
// url
localhost:3055/changes/location/12/4534/2021-09-18T02:33:20/2021-09-19T02:33:20

,但如果你想使用参数名,写这个:

// route
[HttpGet("changes/location")]
// url
localhost:3056/changes/location?page=121&perPage=1233&startTimestamp=2021-09-18T02:33:20&endTimestamp=2021-09-19T02:33:20

最新更新