小编Roh*_*ela的帖子

SharePoint REST API过滤器仅基于今天的日期而非时间。(类似于CAML查询中的IncludeTimeValue = False)

我试图使用今天才创建的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查询中所做的那样)?

rest sharepoint-2013

5
推荐指数
1
解决办法
5186
查看次数

可选参数必须是引用类型,可空类型,或者声明为可选参数.参数名称:参数`

我正在.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 …

c# asp.net-mvc

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

asp.net-mvc ×1

c# ×1

rest ×1

sharepoint-2013 ×1