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.

How to get only one object in sys_user?

Vyacheslav
Kilo Explorer

Hi! 
I want to create parser using VBA and API ServiceNow. For example, I can get all data from sys_user -
https://sninstance.example.ru/api/now/table/sys_user

My result is :

{
"calendar_integration": "1",
"country": "",
"last_login_time": "",
"u_e_mail_financial": "ff@f.com",
"source": "",
"sys_updated_on": "2018-10-24 12:48:31",
"building": "",
"web_service_access_only": "false",
"notification": "2",
"enable_multifactor_authn": "false",
"sys_updated_by": "fff",
"sys_created_on": "2018-09-13 13:29:51",
"sys_domain": {
"link": "sninstance.example.ru/api/now/table/sys_user_group/global",
"value": "global"
},
"state": "",
"vip": "false",
"sys_created_by": "test",
"zip": "",
"home_phone": "",
"time_format": "",
"last_login": "",
"active": "false",
"sys_domain_path": "/",
"u_address_for_sending_documents": "",
"cost_center": "",
"phone": "",
"name": "Ffff ff",
"employee_number": "",
"password_needs_reset": "false",
"gender": "",
"city": "",
"failed_attempts": "",
"user_name": "ff@ff.com",
"title": "",
"sys_class_name": "sys_user",
"sys_id": "000018d9f9e863008ff068a048a5d115",
"u_additional_company": "",
"internal_integration_user": "false",
"ldap_server": "",
"mobile_phone": "",
"street": "",
"company": {
"link": "sninstance.example.ru/api/now/table/core_company/151f9aacf96063008ff068a048a5d1c5",
"value": "151f9aacf96063008ff068a048a5d1c5"
},
"department": "",
"first_name": "Fff",
"email": "fff.ff@ff.com",
"introduction": "",
"preferred_language": "en",
"manager": "",
"u_current_duty": "false",
"locked_out": "true",
"sys_mod_count": "2",
"last_name": "Massa",
"photo": "",
"u_comment": "",
"middle_name": "",
"sys_tags": "",
"time_zone": "",
"schedule": "",
"u_import_id": "704",
"u_email_signature": "",
"u_available": "",
"date_format": "",
"location": ""
},
 

But this records are too much and I don't want to get all data from this sys_user.
I want to get only one user. I want to search by user's email. But I don't know how to do this.

If user is not find, I will get error. If user exist, I will get his data in JSON (check up). How to create this requset. For example  - 

https://ff-ff.ff-ff.ru/api/now/table/sys_user/searchByEmail:email@email.com

5 REPLIES 5

Community Alums
Not applicable

You need to configure the sysparm_limit parameter in order to identify which fields you would like to extract. 

Example:
GET https://instance.service-now.com/api/now/table/sys_user?sysparm_fields=user_name%2Cfirst_name%2Clast_name%2Cpreferred_language%2Cemail%2Csys_id&sysparm_limit=1

I found one which is a good start for you. This give you enough to start to develop your rest ws.

https://github.com/ChaitanyaKaranam/servicenow-rest-api

Thanks,
Raf

Hi! Thank you for your answer! I have one question - how to search by email of user via your example. 

https://instance.service-now.com/api/now/table/sys_user?sysparm_fields=user_name%2Cfirst_name%2Clast_name%2Cpreferred_language%2Cemail: email@email.com %2Csys_id&sysparm_limit=1


I don't know

instance.service-now.com/api/now/table/sys_user/email=ff.ff@ff.com is not work

Community Alums
Not applicable

Have you used REST API Explorer before?

GET https://snqasaas01.service-now.com/api/now/table/sys_user?sysparm_query=user_nameSTARTSWITHrafael.cardoso%40teamultra.net&sysparm_fields=name%2Cuser_name%2Cemail&sysparm_limit=1

Use the sysparm_query to filter your results, you should use an encoded query. The result will return based on sysparm_field. On this case name, user_name and email. 

REST Api Explorer https://developer.servicenow.com/app.do#!/document/content/app_store_doc_rest_integrate_kingston_t_GetStartedAccessExplorer?v=london

Thank you, Raf