Skip to main content

Posts

Showing posts from January, 2022

ServiceNow Incoming REST Response: handling large response with pagination

 example looping through each page of the request data set var r = new sn_ws . RESTMessageV2 ( '<rest_msg_name>' ); var header = r . getRequestHeader ( "Accept" ); var authorization = r . getRequestHeader ( "Authorization" ); r . setStringParameterNoEscape ( "aParam" , aParam ); r . setQueryParameter ( 'aParam2' , aParam ); r . setQueryParameter ( 'per_page' , '20' ); r . setQueryParameter ( 'page' , '1' ); var resp = r . execute (); var responseBody = resp . haveError () ? resp . getErrorMessage () : resp . getBody (); var httpStatus = resp . getStatusCode (); var objC = JSON . parse ( responseBody ); var cPagiNation = objC . pagination . pages ; for ( var cP = 1 ; cP <= cPagiNation ; cP ++) { var r2 = n...