Sample REST: get user email from sys_user table based on userid var request = new sn_ws. RESTMessageV2 (); request.setEndpoint( 'https://xxxxxx.service-now.com/api/now/table/sys_user?sysparm_query=user_name%3Dabel.tuter&sysparm_display_value=true&sysparm_fields=email&sysparm_limit=1' ); request.setHttpMethod( 'GET' ); //Eg. UserName="admin", Password="admin" for this code sample. //--OPTION 1: //var user = 'ruen.test'; //var password = ''; //request.setBasicAuth(user,password); //--OPTION 2: var authentication_type= 'basic' ; var profile_name= '6f7f927f47a346104410edf1d16d4376' ; //--sys_id of sys_auth_profile_basic record request.setAuthenticationProfile(authentication_type, profile_name); request.setRequestHeader( "Accept" , "application/json" ); var response = request.execute(); gs.log( 'RESP=' +response.getBody());
All things ServiceNow... take a look at my channel: https://www.youtube.com/@cloudminus89