- 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 10:01 PM
@Sathyanarayan K If this solution did not work then i will suggest to create a new field with proper name and then move data from "assigned_to (need the empid)" field to the new field through script. And then delete"assigned_to (need the empid)" this field.
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:27 PM
Tried it... but It is not working. That field is not coming in response! It comes only if I remove sysparm_fields completely it is coming...
Yea somehow that Spaced Column Name or Column Label is sitting there causing issues. Unfortunately per business requirements, I can not ignore that field and also I can not bring all the data as its going to cost too much on performance front
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2022 10:04 PM
you should use column names in sysparm_fields and column name in servicenow won't contain any space
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2022 07:32 AM
Thank you! Is there a way to get column names that I am not exposed to or not aware of from API response itself with some parameters?