- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2015 08:58 AM
I have written a Ruby gem for ServiceNow that allows me to fully interact with ServiceNow. It currently uses the JSONv2 API. Everything works splendidly but it's slow and there is a record limit of 500. I recently discovered the REST API which is much faster and has a record limit of 10,000.
However, I am seeing inconsistencies in the results set between the two for the same exact call. I currently having debug output displaying the record count. I've tried to figure it out. It looks like the results get skewed as soon as I enter more configuration item names to the list. I am wondering if I am hitting the limit for GET requests or something.
JSONv2 looks like this:
./test.rb --ci "IDManager (IAM 2.0),UnboundID,HA TicketServer,Partner Authentication Gateway,Authentication (UniAuth),Web & Hosting Platform (WHP),IDFederation,Identity Data eXchange (IDX),IDProfile,AssetID,OAuth 2.0,Identity User eXperience (IUX),IDManager (IAM),Util Data eXchange (UDX),OAuth,Subscription Data eXchange (SDX),Identity Universal Service (IUS),IDAudit" --start 2015-04-01 --end 2015-08-01
[Debug] executing method: incident_find
[Debug] fetching https://foo.service-now.com/api/now/v1/table/incident?sysparm_display_value=true&sysparm_query=u_maj... (IAM 2.0),UnboundID,HA TicketServer,Partner Authentication Gateway,Authentication (UniAuth),Web & Hosting Platform (WHP),IDFederation,Identity Data eXchange (IDX),IDProfile,AssetID,OAuth 2.0,Identity User eXperience (IUX),IDManager (IAM),Util Data eXchange (UDX),OAuth,Subscription Data eXchange (SDX),Identity Universal Service (IUS),IDAudit
[Debug] JSON payload: null
4 records found.
REST looks like this:
./test.rb --ci "IDManager (IAM 2.0),UnboundID,HA TicketServer,Partner Authentication Gateway,Authentication (UniAuth),Web & Hosting Platform (WHP),IDFederation,Identity Data eXchange (IDX),IDProfile,AssetID,OAuth 2.0,Identity User eXperience (IUX),IDManager (IAM),Util Data eXchange (UDX),OAuth,Subscription Data eXchange (SDX),Identity Universal Service (IUS),IDAudit" --start 2015-04-01 --end 2015-08-01
[Debug] executing method: incident_find
[Debug] fetching https://foo.service-now.com/incident_list.do?JSONv2&displayvalue=true&sysparm_view=json_view
[Debug] JSON payload: {"sysparm_action":"getRecords","sysparm_query":"u_major_incident=true^cmdb_ci.nameINIDManager (IAM 2.0),UnboundID,HA TicketServer,Partner Authentication Gateway,Authentication (UniAuth),Web & Hosting Platform (WHP),IDFederation,Identity Data eXchange (IDX),IDProfile,AssetID,OAuth 2.0,Identity User eXperience (IUX),IDManager (IAM),Util Data eXchange (UDX),OAuth,Subscription Data eXchange (SDX),Identity Universal Service (IUS),IDAudit"}
36 records found.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-23-2015 01:48 PM
I solved it. One of my CIs has an ampersand in its name and URI encoding it does not encode the ampersand so it is tripping up the URL processing. Converting the ampersand to a percent code before making a call to the REST API solved the problem.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2015 09:13 AM
There are differences in the results between the two different types of web service calls.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2015 09:18 AM
Why would the same request to SNow return different results based on which API I am using? That makes no sense.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2015 09:17 AM
If I take the list of CIs that actually have data and limit my request to include only those CIs, the REST API returns the correct information.
./test.rb --ci "Identity Universal Service (IUS),OAuth,IDManager (IAM),OAuth 2.0,IDManager (IAM)" --start 2015-04-01 --end 2015-08-01
[Debug] executing method: incident_find
[Debug] fetching https://foo.service-now.com/api/now/v1/table/incident?sysparm_display_value=true&sysparm_query=u_maj... Universal Service (IUS),OAuth,IDManager (IAM),OAuth 2.0,IDManager (IAM)^u_start_date>=2015-04-01^u_start_date<=2015-08-01
[Debug] JSON payload: null
11 records found.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2015 09:29 AM
That is interesting. It is as if the sysparm_query is not being captured by one of your calls. I was able to get expected results using JSONv2 vs Advanced REST Client in my dev instance.