servicestack - Servicestack Gateway.Send 不适用于 POST
问题描述
我有这个服务方法
public async Task Post(DeviceEndpointInsertTemp request)
{
//Some AYNC Code
}
我这样称呼它
var model = new DeviceEndpointInsertTemp() {DeviceNumber = deviceID, IOEndpointList = list, EventGridPostDateTime = postTime};
var task = Gateway.SendAsync(model);
await task; //wait for response
我收到这个错误
{"Could not find method named Put(DeviceEndpointInsertTemp) or Any(DeviceEndpointInsertTemp) on Service IntegrationService"}
直到我将 POST 更改为 ANY
public async Task ANY(DeviceEndpointInsertTemp request)
{
//Some AYNC Code
}
你知道为什么吗?
解决方案
这在Service Gateway Docs中有解释:
不带注释的裸请求 DTO 作为POST发送,但使用HTTP 动词接口标记注释请求 DTO 也支持替代动词,其中包含IGet
,IPut
等的请求 DTO 使用类型化动词 API 发送,例如:
[Route("/customers/{Id}")]
public class GetCustomer : IGet, IReturn<Customer>
{
public int Id { get; set ;}
}
因此,如果您想发送服务网关来发送PUT请求,您的请求 DTO 需要实现适当的HTTP 动词接口标记,例如:
public class DeviceEndpointInsertTemp : IPut, IReturn<TheResponse>
{
//...
}
推荐阅读
- visual-foxpro - vDos 阿拉伯语代码页问题
- python - 在 Flask 应用程序中运行计划任务时出现线程错误
- javascript - 如何在不打开打印对话框的情况下从共享主机打印到本地连接的热敏打印机
- vue.js - Traversy Media vue课程在vue中服务的问题
- node.js - 等价于 prisma 中的 mongoose schema.pre
- javascript - 预期对应的 JSX 结束标记
(16:12) - flutter - SearchDelegate TextField 不尊重 InputDecoration
- android - 应用程序关闭时服务不起作用,尽管之前有
- javascript - 如何在不刷新的情况下以 ajax 发送带有多个文件的表单数据?
- python - 在训练模式下,目标应该通过