【发布时间】:2019-07-08 19:23:21
【问题描述】:
我有一个用 C# 编写的端点,它应该接收一个对象作为函数的参数。出于测试目的,该对象只有两个属性:Active 和 Deleted。当我在 Postman 中设置对象以测试 Active 的值为 true 和 Deleted 的值为 false 或反之亦然的端点时,这些值将被忽略并且端点返回两个属性的值都设置为 false 的对象.
这是控制器中的方法:
[HttpPost]
public dynamic Courses(long? courseId, CourseFilter paramsObject)
{
//Create an instance of the CourseService class
CourseService course = new CourseService();
//Return the result of the GetAllCourses method in the CourseService class
//return course.Courses(courseId, paramsObject);
return ("Active: " + paramsObject.Active + " " + "Deleted: " + paramsObject.Deleted);
return paramsObject;
}
请注意,我只是使用 dynamic 并返回对象只是为了测试和调试目的,以查看值是否正确。
这是 Postman 中对象的图片:
谢谢
【问题讨论】: