我试图使用今天才创建的REST API从SharePoint列表中获取数据。
var listName = "Carousel%20News";
var today = new Date().toISOString();
Run Code Online (Sandbox Code Playgroud)
这是我的REST URL:
_spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('" + listName + "')/items?$select=Id,Title&$filter=Created eq '" + today + "'";
Run Code Online (Sandbox Code Playgroud)
但是,当我使用此剩余URL时,我没有得到今天创建的项目。
(我仔细检查了列表中是否存在具有今天创建日期的项目)
我的假设是,此URL根据日期和时间值进行过滤。
因此,有没有办法我可以仅将REST过滤器用于今天的日期,而忽略时间戳(就像我们IncludeTimeValue=False在CAML查询中所做的那样)?
我正在.net MVC中创建一个演示应用程序.
下面是我的StudentController的代码片段.
public ActionResult Edit(int studentId)
{
var std = studentList.Where(s => s.StudentId == studentId).FirstOrDefault();
return View(std);
}
[HttpPost]
public ActionResult Edit(Student std)
{
//write code to update student
return RedirectToAction("Index");
}
Run Code Online (Sandbox Code Playgroud)
来自RouteConfig的代码片段:
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
Run Code Online (Sandbox Code Playgroud)
当我点击url时,http://localhost:54977/student/Edit/1我会遇到异常.
The parameters dictionary contains a null entry for parameter 'studentId' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Edit(Int32)' in 'MVC1.Controllers.StudentController'. An optional parameter …