[英]Return two responses different responses from the Rest API
I am having an API which returns the response in the format [{"Acc":"adm","Cnt":"087","Yr":"17"}]. 我有一个API,它以[{“ Acc”:“ adm”,“ Cnt”:“ 087”,“ Yr”:“ 17”}]的格式返回响应。
var response_EndPoint = await client_EndPoint.GetAsync(EndPoint_URL);
var projectDetails = await response_EndPoint.Content.ReadAsAsync<Model[]>();
return Ok(projectDetails);
Now I am checking if there is a way to extend this Rest API to send two responses one is [{"Acc":"adm","Cnt":"087","Yr":"17"}] and the other is 17-adm-087 现在,我正在检查是否有扩展此Rest API的方法来发送两个响应,一个是[{“ Acc”:“ adm”,“ Cnt”:“ 087”,“ Yr”:“ 17”}],另一个是17-adm-087
foreach (Model res in projectName)
{
string serviceResponse = string.Format("{0}-{1}-{2}", res.Yr,res.Acc, res.Cnt);
}
I am constructing the string but not sure if there is any possibility of sending both the responses. 我正在构造字符串,但不确定是否有可能发送两个响应。
You cannot send two responses from one endpoint but you can merge the result into one response. 您不能从一个端点发送两个响应,但是可以将结果合并为一个响应。 If you need two totally different responses you have two options. 如果您需要两个完全不同的响应,则有两个选择。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.