Querying end point fields that has Space in it

Sathyanarayan K
Giga Contributor

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 

 

{
    "result": [
        {
            "number""TK00001"
        }
}
 
If my URI is
 
 
Then I get the result
 
{
    "result": [
        {
            "number""TK00001",
            "assigned_to (need the empid)":"MYQ001",
            "Other_Field1":"Other Value 1",
             : 
             "Other_FieldN":"Other Value N"
        }
}
 
So how do I pass the column names that has Spaces and parenthesis like  "assigned_to (need the empid)"
 
Thanks for the Help in Advance
2 ACCEPTED SOLUTIONS

jaheerhattiwale
Mega Sage
Mega Sage

@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.

 

 

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

View solution in original post

Hi @Sathyanarayan K 

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 .

 

 

 

Please mark my answer as correct and helpful based on Impact.

View solution in original post

8 REPLIES 8

newhand
Mega Sage

HI@Sathyanarayan K 

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.

 

Please mark my answer as correct and helpful based on Impact.

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.

Hi @Sathyanarayan K 

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 .

 

 

 

Please mark my answer as correct and helpful based on Impact.

jaheerhattiwale
Mega Sage
Mega Sage

@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.

 

 

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023