Service Now API指定CSV格式的字段



我正试图从活动的Service Now获取事件列表。我只需要一个特定的字段称为due_date从数据。如果我使用JSON

curl -s -L --user username:password --header "Accept: application/json" --header "Content-Type:application/json" "https://myservicenow.com/api/now/table/incident?sysparm_query=opened_atRELATIVEGE@dayofweek@ago@100"
我得到一个URL,比如
    {
        "active": "true",
        ......
        "due_date": "2015-07-22 07:07:28",
    }

我想使用CSV web服务做同样的事情。所以我使用

curl -s -L --user username:password "https://myservicenow.com/incident.do?CSV&sysparm_query=opened_atRELATIVEGE@dayofweek@ago@100"

我得到像

这样的字段
"number","sys_created_by","caller_id","short_description","subcategory","u_subcategory_detail","category","priority","state","assignment_group","assigned_to","opened_at","resolved_at"

但是due_date字段不存在。如何指定要以CSV格式检索的字段?

CSV卸载程序正在根据所讨论的表的UI视图转储字段。出现在UI View上的字段是包含在你的输出中的字段。由于您没有显式指定视图,因此使用"默认视图",就像如果您在应用程序中加载列表而没有指定sysparm_view URL参数一样。

你可以这样做:

  • 进入实例,打开表的列表(例如/incident_list.do)
  • 通过Personalize/Configure List修改视图,添加due_date
    • 不要使用齿轮列表个性化,这实际上不会改变视图
  • 再次尝试您的CSV拉,您应该有due_date列包括!

现在,如果你实际上不想改变你的默认视图,你可以在目标表上创建一个新的UI视图(给它一个像'csv_dump'这样的名字),然后将参数sysparm_view=csv_dump添加到你的URL,这样:

curl -s -L --user username:password "https://myservicenow.com/incident.do?CSV&sysparm_view=csv_dump&sysparm_query=opened_atRELATIVEGE@dayofweek@ago@100"

将sysparm_view的值作为创建UI视图时使用的任何名称。

最新更新