- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2022 06:47 PM
Need help in GET request of Rest API by passing the fields in sysparm_fields.
I trying to query a Table via Rest API URI by passing only a limited number of columns of the table using Sysparam_fields.
However few column names have Spaces and parenthesis in it. So the JSON result set is excluding those columns and respective data when I do a GET request.
So if I am querying with column names "assigned_to (need the empid)" and "Number", I only get "Number" data.
If I dont pass, sysparm_fields it is returning the result set with all the columns including "assigned_to (need the empid)"
My end point looks like this
https://MyInstance.service-now.com/api/now/table/ticket?sysparm_exclude_reference_link=true&sysparm_... (need the empid)&sysparm_query=sys_updated_onBETWEENjavascript:gs.dateGenerate('2020-09-01','00:00:00')@javascript:gs.dateGenerate('2020-09-01','23:59:59')
The result is only
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2022 09:11 PM
@Sathyanarayan K Actually "assigned_to (need the empid)" this field name is not valid as servicenow replaces spaces as _ in field name. But as you received it in response from the table api. This field might be created some how in the system.
You can try to replace the field name is URL from "assigned_to (need the empid)" to "assigned_to%20(need%20the%20empid)"
Please mark as correct answer if this solves your issue.
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2022 09:56 PM - edited 12-05-2022 09:56 PM
It seems that "assigned_to (need the empid)" is Column Names althought i don't know how to set the Column Names to a invalid value(I tried to change my column name to the same as yours, but i failed).
There is another parameter "sysparm_view" .
Create a new view just include the columns you need ,and run the restapi whith this parameter .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2022 08:11 PM
You should put "Column name" into sysparm_fields , not "Column label".
And the special charactors such as "parenthesis , space " will be removed from "Column name" when you create a new column,so the case you writed will never happen.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2022 08:47 PM
How to find the Column Names? I got these Column labels from the JSON response that I got when I did not include sysparm_fields.
I don't have access to this table so trying to figure things out by myself without much inputs from anyone from the source system.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2022 09:56 PM - edited 12-05-2022 09:56 PM
It seems that "assigned_to (need the empid)" is Column Names althought i don't know how to set the Column Names to a invalid value(I tried to change my column name to the same as yours, but i failed).
There is another parameter "sysparm_view" .
Create a new view just include the columns you need ,and run the restapi whith this parameter .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2022 09:11 PM
@Sathyanarayan K Actually "assigned_to (need the empid)" this field name is not valid as servicenow replaces spaces as _ in field name. But as you received it in response from the table api. This field might be created some how in the system.
You can try to replace the field name is URL from "assigned_to (need the empid)" to "assigned_to%20(need%20the%20empid)"
Please mark as correct answer if this solves your issue.
ServiceNow Community Rising Star, Class of 2023