I am trying to get a list of incidents from Service Now which is active. I just need a specific field called due_date from the data. If I use 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"
I get a URL like
{
"active": "true",
......
"due_date": "2015-07-22 07:07:28",
}
I want to do the same thing using CSV web service. So I used
curl -s -L --user username:password "https://myservicenow.com/incident.do?CSV&sysparm_query=opened_atRELATIVEGE@dayofweek@ago@100"
I get fields like
"number","sys_created_by","caller_id","short_description","subcategory","u_subcategory_detail","category","priority","state","assignment_group","assigned_to","opened_at","resolved_at"
But the field due_date is not present. How can I specify the fields to retrieve in CSV format ?
The CSV unloader is dumping fields based on a UI View for the table in question. The fields that are present on the UI View are the ones that get included in your output. Since you have not explicitly specified a view, the "Default view" is used, just like if you were to load a list within the application without a sysparm_view URL parameter specified.
Here's what you can do:
due_date column
Now, if you don't actually want to change your default view, you can create a new UI View on the target table (give it a name like 'csv_dump'), and then add the parameter sysparm_view=csv_dump to your URL, thusly:
curl -s -L --user username:password "https://myservicenow.com/incident.do?CSV&sysparm_view=csv_dump&sysparm_query=opened_atRELATIVEGE@dayofweek@ago@100"
...passing the value for sysparm_view as whatever name you used to create your UI View.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With