立即服务 API 在 CSV 中指定字段
Service Now API specify fields in CSV
我正在尝试从“立即服务”中获取活动的事件列表。我只需要数据中一个名为 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 网络服务做同样的事情。所以我用了
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 卸载程序正在为有问题的 table 转储基于 UI View 的字段。 UI 视图中出现的字段是包含在输出中的字段。由于您没有明确指定视图,因此使用 "Default view",就像您在没有指定 sysparm_view
URL 参数的应用程序中加载列表一样。
您可以执行以下操作:
- 转到实例并打开 table 的列表(例如 /incident_list.do)
- 通过 Personalize/Configure 列表修改您的视图以添加
due_date
列
- 不要使用 Cog-wheel 列表个性化,这实际上不会改变视图
- 再次尝试您的 CSV 拉取,您应该包含 due_date 列!
现在,如果您实际上不想更改默认视图,您可以在目标 table 上创建一个新的 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 视图的任何名称传递。
我正在尝试从“立即服务”中获取活动的事件列表。我只需要数据中一个名为 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 网络服务做同样的事情。所以我用了
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 卸载程序正在为有问题的 table 转储基于 UI View 的字段。 UI 视图中出现的字段是包含在输出中的字段。由于您没有明确指定视图,因此使用 "Default view",就像您在没有指定 sysparm_view
URL 参数的应用程序中加载列表一样。
您可以执行以下操作:
- 转到实例并打开 table 的列表(例如 /incident_list.do)
- 通过 Personalize/Configure 列表修改您的视图以添加
due_date
列- 不要使用 Cog-wheel 列表个性化,这实际上不会改变视图
- 再次尝试您的 CSV 拉取,您应该包含 due_date 列!
现在,如果您实际上不想更改默认视图,您可以在目标 table 上创建一个新的 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 视图的任何名称传递。