Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Why does sysparm not work for me

John Wallis
Kilo Contributor

I think anything involving the use of "sysparm_" does not work on POSTMAN!

This works in the SNow 'REST API Explorer' area.
sysparm_fields=sys_updated_on%2Csys_id

But: when I use the same string, same format, it doesn't work in the real situation.

[I went to the my dev ... area, and did a "REST API Explorer" query and the ... creates a wonderful query for me and appears to work within that environment.

Note: "limit" alone works, but "sysparm_limit" does not work.

My goal is to use something like this [original issue]
sysparm_query:sys_updated_on>javascript:gs.dateGenerate('2020-02-14','00:00:00')
and maybe the limit the fields 

confused 😕

 

 

 

7 REPLIES 7

Tony Chatfield1
Kilo Patron

Hi, postman can get confused occasionally and may need cookies cleared, or you may just need to start with a new GET record.

You haven't provided any details of your postman configuration, so I won't guess as to what\why
but here's an example of sysparm config I've just knocked up and tested in a vanilla dev instance.

sysparm_query is an encoded query via sys_user 'copy query'
sysparm_fields was copied from a rest api explorer request, just to confirm the format.

the query returns up to 63 record with OOB data (at least for me) and sysparm_limit seems to return correctly with any variation

 

 

find_real_file.png

 

Hi Tony, I am fully convinced what your doing works for you, and indeed in the SN-environment the queries work for me also, but for me in a non-SN-environment, for some reason, only a few of the parameters seem to work. I think the problem is something other than 'syntax.'

[hypothetically:] Could I somehow create a REST-API that would limit the possible parameters?
Could I make a new-parameter, say 'limit', that users could use?

[Current issue] Attempt:
I made a new GET-tab and also cleared all cookies: Did not help, but eagerly tried them out.

I took postman's code for powershell, which gave me: (below).
It seems whatever constellation I try,
1. only the limit and offset parameters work.
2. The sysparm_fields, sysparm_query don't have any effect and
3. sysparm_limit doesn't work either. [as long as 'limit' works, I'm ok]

ps1:

$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", "Basic TopSecretPassword")
$URL0 = 'https://[myCO]/api/snc/v2/co_rest_api/[guid]/GetCostCenterList?sysparm_limit=2&offset=10'
$URL0 = 'https://[myCo].service-now.com/api/snc/v2/co_rest_api/[guid]/[table]?limit=2&offset=10'
$URL1 = '&sysparm_fields=sys_updated_on%2Csys_id'
$URL1 = '&sysparm_fields=sys_updated_on,sys_id'
$URL2 = ''
$URL1 = '&fields=sys_updated_on,sys_id'
#$URL2 = '&sysparm_query:sys_updated_on>=2020-01-31 07:00:00^ORDERBYsys_updated_on'
#$URL2 = '&sysparm_query:sys_updated_on>=2020-01-31 07:00:00'
#$URL3 = '^ORDERBYsys_updated_on'
$URL3 = ''
$url = $URL0 + $URL1 + $URL2 + $URL3
$response = Invoke-RestMethod $url -Method 'GET' -Headers $headers -Body $body

{
"result": [
{
"u_telecommunication": "0",
"u_outsourced_service": "0",
"sys_created_on": "2019-05-17 13:04:18",
"sys_updated_on": "2019-09-30 03:22:16",
"sys_id": "[guid]",
...[~40 fields]
},
...
]
}

The url here is 

https://....?limit=2&offset=10&fields=sys_updated_on,sys_id

Hi John, attached is json file collection for a single postman GET message.
To test you would need to update the URL, access token, client_id and client_secret headers;
It should be enough to confirm functionality in your company dev instance as the fields are all OOB - unless there is local code or security restrictions that prevent it from running correctly.

 

Sorry, saving again with the right file

Thanks, for this. Where I work is quite secure: Each individual rest requires a grant. I'm asking the folks in several time-zones about this issue - Thanks for your help.

Sorry I got upset [if you noticed ...].