我正试图在ASP.NET Boilerplate上启动我的项目。
我现在正在创建动态Web API,以下是我的代码:
我的AppService:
public interface IBorrowLendAppService : IApplicationService
{
GetBorrowLendsOutput GetBorrowLends(GetBorrowLendsInput input);
}
我的输入:
public class GetBorrowLendsInput : IInputDto
{
public byte ItemType { get; set; }
public int PersonId { get; set; }
}
以下是我的问题:
- 如何调用此方法?
- 如何创建GET / POST方法(Boilerplate文档中没有相关信息)
当我调用不带任何数据的方法[GET]GetBorrowLends时,我收到错误消息:
{
"result": null,
"success": false,
"error": {
"code": 0,
"message": "Your request is not valid!",
"details": null,
"validationErrors": [
{
"message": "input is null!",
"members": [
"input"
]
}
]
},
"unAuthorizedRequest": false
}
当我试图调用它时,如下所示:
.../GetBorrowLends?ItemType=0&PersonId=1
我收到了相同的错误。
使用以下数据调用[POST]:
{
"input":{
"ItemType":"0",
"PersonId":"1"
}
}
返回另一个错误:
{
"result": null,
"success": false,
"error": {
"code": 0,
"message": "An internal error occured during your request!",
"details": null,
"validationErrors": null
},
"unAuthorizedRequest": false
}
我该如何处理这个问题?以及如何手动创建GET/POST方法?
谢谢。
编辑:
我已经解决了无法工作的端点问题。我在POST消息中错误地设置了“Content-Type”参数。
但是有关ApplicationService中GET/POST方法的问题仍然存在。