{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":546,"path":"api-reference/rest-apis/scriptdebugger-api.md","title":"Script Debugger API","bundle":null,"doc_type":null,"release":"australia","body":"\n# Script Debugger API\n\nThe Script Debugger API provides endpoints to debug lines of server-side JavaScript code, such as business rules and script includes.\n\nFor more information about the Script Debugger, see [Script Debugger and Session Log](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/scripts/script-debugger.md).\n\nThis API is available by default.\n\n**Parent Topic:**[REST API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-apis/api-rest.md)\n\n## Script Debugger - GET /js/debugpoints/script/\\{tableName\\}/\\{sysId\\}/\\{fieldName\\}\n\nRetrieve a list of breakpoints or logpoints in a server-side script, such as a business rule or script include.\n\n### URL format\n\nDefault URL: `/api/now/js/debugpoints/script/{tableName}/{sysId}/{fieldName}`\n\n### Supported request parameters\n\n<table class=\"rest_api_path_parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\ntableName\n\n</td><td>\n\nName of the table that contains the server-side script, such as sys\\_script or sys\\_script\\_include.Data type: String\n\n</td></tr><tr><td>\n\nsysId\n\n</td><td>\n\nSys\\_id for the server-side script.Data type: String\n\n</td></tr><tr><td>\n\nfieldName\n\n</td><td>\n\nName of the field that contains the server-side script content.Data type: String\n\n</td></tr></tbody>\n</table>|Name|Description|\n|----|-----------|\n|None| |\n\n|Name|Description|\n|----|-----------|\n|None| |\n\n### Headers\n\nThe following request and response headers apply to this HTTP action only, or apply to this action in a distinct way. For a list of general headers used in the REST API, see [Supported REST API headers](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/c_RESTAPI.md).\n\n<table class=\"rest_api_request_headers\"><thead><tr><th>\n\nHeader\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nAccept\n\n</td><td id=\"accept-entry-RESTAPI\">\n\nData format of the response body. Supported types: **application/json** or **application/xml**. Default: **application/json**\n\n</td></tr></tbody>\n</table>|Header|Description|\n|------|-----------|\n|None| |\n\n### Status codes\n\nThe following status codes apply to this HTTP action. For a list of possible status codes used in the REST API, see [REST API HTTP response codes](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/c_RESTAPI.md).\n\n|Status code|Description|\n|-----------|-----------|\n|200|Successful. The request was successfully processed.|\n|403|User Not Authorized. The user who executed the request does not have permission to access breakpoint or log point information for the specified record.|\n\n### Response body parameters \\(JSON or XML\\)\n\n<table><thead><tr><th>\n\nName\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\ncanWrite\n\n</td><td>\n\nFlag indicating whether the currently logged in user can set or modify breakpoints for the script.Possible values:\n\n-   true: You can set or modify breakpoints.\n-   false: You cannot set or modify breakpoints.\n\n Data type: Boolean\n\n</td></tr><tr><td>\n\ndebugpoints\n\n</td><td>\n\nList of all the breakpoints and logpoints in the script.```\n\"debugpoints\": {\n  \"breakpoint\": {Object}\n  \"logpoint\": {Object}\n}\n```\n\n Data type: Object\n\n</td></tr><tr><td>\n\ndebugpoints.breakpoint\n\n</td><td>\n\nList of all the breakpoints in the script, presented as key-value pairs. The key is the line number for the breakpoint. The value is an object containing the breakpoint's sys\\_id and text.```\n\"breakpoint\": {\n  <line_number>: {Object}\n}\n```\n\n Data type: Object\n\n</td></tr><tr><td>\n\ndebugpoints.breakpoint.&lt;line\\_number&gt;\n\n</td><td>\n\nLine number for the breakpoint.```\n<line_number>: {\n  \"evaluationString\": \"String\"\n  \"sysId\": \"String\"\n}\n```\n\n Data type: Object\n\n</td></tr><tr><td>\n\ndebugpoints.breakpoint.&lt;line\\_number&gt;.evaluationString\n\n</td><td>\n\nText of the breakpoint. If the breakpoint is conditional, the evaluationString contains the condition text. If the breakpoint is not conditional, the evaluationString is an empty string. Data type: String\n\n</td></tr><tr><td>\n\ndebugpoints.breakpoint.&lt;line\\_number&gt;.sysId\n\n</td><td>\n\nSys\\_id of the breakpoint.Data type: String\n\n</td></tr><tr><td>\n\ndebugpoints.logpoint\n\n</td><td>\n\nList of all the logpoints in the script, presented as key-value pairs. The key is the line number for the logpoint. The value is an object containing the logpoint's sys\\_id and text.```\n\"logpoint\": {\n  <line_number>: {Object}\n}\n```\n\n Data type: Object\n\n</td></tr><tr><td>\n\ndebugpoints.logpoint.&lt;line\\_number&gt;\n\n</td><td>\n\nLine number for the logpoint.```\n<line_number>: {\n  \"evaluationString\": \"String\"\n  \"sysId\": \"String\"\n}\n```\n\n Data type: Object\n\n</td></tr><tr><td>\n\ndebugpoints.logpoint.&lt;line\\_number&gt;.evaluationString\n\n</td><td>\n\nText of the logpoint. Contains the message being logged.Data type: String\n\n</td></tr><tr><td>\n\ndebugpoints.logpoint.&lt;line\\_number&gt;.sysId\n\n</td><td>\n\nSys\\_id of the logpoint.Data type: String\n\n</td></tr><tr><td>\n\nkey\n\n</td><td>\n\nObject providing details about the script being debugged. ```\n\"key\": {\n  \"scriptField\": \"String\"\n  \"scriptId\": \"String\"\n  \"scriptType\": \"String\"\n  \"value\": \"String\"\n}\n```\n\n Data type: Object\n\n</td></tr><tr><td>\n\nkey.scriptField\n\n</td><td>\n\nName of the field that contains the script.Data type: String\n\n</td></tr><tr><td>\n\nkey.scriptId\n\n</td><td>\n\nSys\\_id of the script.Data type: String\n\n</td></tr><tr><td>\n\nkey.scriptType\n\n</td><td>\n\nName of the table that contains the script.Data type: String\n\n</td></tr><tr><td>\n\nkey.value\n\n</td><td>\n\nThe path parameters used to make the request. Listed in the following order.-   tableName\n-   sysId\n-   fieldName\n\n Data type: String\n\n</td></tr><tr><td>\n\nname\n\n</td><td>\n\nName of the script.Data type: String\n\n</td></tr><tr><td>\n\nscript\n\n</td><td>\n\nText displaying the script's code.Data type: String\n\n</td></tr></tbody>\n</table>### Example cURL request\n\n### cURL request\n\nRetrieves a list of logpoints and breakpoints for a server-side script. This script has a logpoint on line 2, a breakpoint on line 11, and a conditional breakpoint on line 18.\n\n```\ncurl \"https://instance.servicenow.com/api/now/js/debugpoints/script/sys_script_include/d65f78c40a0a0b6900196656f35913d3/script\" \\\n--request GET \\\n--header \"Accept:application/json\" \\\n--header \"Content-Type:application/json\" \\\n--user 'username':'password'\n```\n\n```\n{\n  \"result\": {\n    \"canWrite\": true,\n    \"debugpoints\": {\n      \"LOGPOINT\": {\n        \"2\": {\n          \"evaluationString\": \"A log message\",\n          \"sysId\": \"ba28b0fa739310101c233096fbf6a75e\"\n        }\n      },\n      \"BREAKPOINT\": {\n        \"11\": {\n          \"evaluationString\": \"\",\n          \"sysId\": \"dc5f5bf341256010f877587fbdf5ec1d\"\n        },\n        \"18\": {\n          \"evaluationString\": \"a == true\",\n          \"sysId\": \"3d4f5bf341256010f877587bdf5ecf6\"\n        }\n      }\n    },\n    \"script\": \"// script code\",\n    \"name\": \"AbstractAjaxProcessor\",\n    \"key\": {\n      \"scriptType\": \"sys_script_include\",\n      \"scriptId\": \"d65f78c40a0a0b6900196656f35913d3\",\n      \"scriptField\": \"script\",\n      \"value\": \"sys_script_include.d65f78c40a0a0b6900196656f35913d3.script\"\n    }\n  }\n}\n```\n\n## Script Debugger - POST js/debugpoints/process\n\nAdd, update, or remove breakpoints or logpoints in a server-side script, such as a business rule or script include. Process several breakpoints or logpoints at a time.\n\n### URL format\n\nDefault URL: `/api/now/js/debugpoints/process`\n\n### Supported request parameters\n\n|Name|Description|\n|----|-----------|\n|None| |\n\n<table class=\"rest_api_query_parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nfetchAll\n\n</td><td>\n\nWhen true, returns a list of all the breakpoints or logpoints added or updated by the user.Data type: Boolean\n\n Default: false\n\n</td></tr><tr><td>\n\nfetchAllFilter\n\n</td><td>\n\nReturns a filtered list of all the breakpoints or logpoints added or updated by the user.\n\n Valid values:\n\n-   debugpointType. Set to either breakpoint or logpoint.\n-   scriptId. Set to the sys\\_id of the script in which to search for debug points.\n-   scope. Set to the name of the scope in which to search for debug points.\n\n Use the caret \\(^\\) symbol as a separator for multiple properties. For example, `fetchAllFilter=debugpointType=logpoint^scope=MyApp`\n\n Data type: String\n\n</td></tr></tbody>\n</table><table class=\"rest_api_request_body\"><thead><tr><th>\n\nName\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\ndebugpointType\n\n</td><td>\n\nRequired. Type of debug point to add, delete, or update.\n\n Valid values:\n\n-   breakpoint\n-   logpoint\n\n Data type: String\n\n</td></tr><tr><td>\n\nevaluationString\n\n</td><td>\n\nText for a logpoint or conditional breakpoint.\n\n For a logpoint, the **evaluationString** is the log message.\n\n For a conditional breakpoint, the **evaluationString** is the condition. For example, if you're looping through a list of user IDs and you want the debugger to pause only when the user ID is 38493, you can add a conditional breakpoint inside the loop with `userID == 38493` as the condition. The debugger will only pause at this breakpoint when the condition is true.\n\n If the breakpoint is not a conditional breakpoint, the **evaluationString** is an empty string.\n\n Data type: String\n\n</td></tr><tr><td>\n\nfieldName\n\n</td><td>\n\nRequired. Name of the field that contains the server-side script content.Data type: String\n\n</td></tr><tr><td>\n\nlineNumber\n\n</td><td>\n\nLine number in the server-side script specifying where to add, delete, or update the breakpoint or logpoint.Data type: Number\n\n</td></tr><tr><td>\n\noperation\n\n</td><td>\n\nRequired. Operation to perform for the breakpoint or logpoint.Valid values:\n\n-   add\n-   delete\n-   update\n\n Data type: String\n\n</td></tr><tr><td>\n\nscriptId\n\n</td><td>\n\nRequired. Sys\\_id for the server-side script.Data type: String\n\n</td></tr><tr><td>\n\ntableName\n\n</td><td>\n\nRequired. Name of the table that contains the server-side script, such as sys\\_script or sys\\_script\\_include.Data type: String\n\n</td></tr></tbody>\n</table>### Headers\n\nThe following request and response headers apply to this HTTP action only, or apply to this action in a distinct way. For a list of general headers used in the REST API, see [Supported REST API headers](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/c_RESTAPI.md).\n\n<table class=\"rest_api_request_headers\"><thead><tr><th>\n\nHeader\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nAccept\n\n</td><td id=\"accept-entry-RESTAPI\">\n\nData format of the response body. Supported types: **application/json** or **application/xml**. Default: **application/json**\n\n</td></tr><tr><td>\n\nContent-Type\n\n</td><td>\n\nData format of the request body. Supported types: **application/json** or **application/xml**. Default: **application/json**\n\n</td></tr></tbody>\n</table>|Header|Description|\n|------|-----------|\n|None| |\n\n### Status codes\n\nThe following status codes apply to this HTTP action. For a list of possible status codes used in the REST API, see [REST API HTTP response codes](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/c_RESTAPI.md).\n\n|Status code|Description|\n|-----------|-----------|\n|200|Successful. The request was successfully processed.|\n\n### Response body parameters \\(JSON or XML\\)\n\n<table><thead><tr><th>\n\nName\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nrequestedDebugpoints\n\n</td><td>\n\nList of the requested breakpoints and logpoints. Presented as an array of objects.```\n\"requestedDebugpoints\": [\n  {\n    \"scriptId\": \"String\",\n    \"evaluationString\": \"String\",\n    \"operation\": \"String\",\n    \"tableName\": \"String\",\n    \"fieldName\": \"String\",\n    \"status\": \"String\",\n    \"lineNumber\": Number,\n    \"debugpointType\": \"String\"\n  }\n]\n```\n\n Data type: Array\n\n</td></tr><tr><td>\n\nrequestedDebugpoints.ScriptId\n\n</td><td>\n\nSys\\_id for the server-side script.Data type: String\n\n</td></tr><tr><td>\n\nrequestedDebugpoints.evaluationString\n\n</td><td>\n\nText added for a logpoint or conditional breakpoint. For a logpoint, the **evaluationString** is the log message. For a conditional breakpoint, the **evaluationString** is the condition. Data type: String\n\n</td></tr><tr><td>\n\nrequestedDebugpoints.operation\n\n</td><td>\n\nOperation performed for the breakpoint or logpoint.\n\n Possible values:\n\n-   add\n-   delete\n-   update\n\n Data type: String\n\n</td></tr><tr><td>\n\nrequestedDebugpoints.tableName\n\n</td><td>\n\nName of the table that contains the server-side script, such as sys\\_script or sys\\_script\\_include.Data type: String\n\n</td></tr><tr><td>\n\nrequestedDebugpoints.fieldName\n\n</td><td>\n\nName of the field that contains the server-side script content.Data type: String\n\n</td></tr><tr><td>\n\nrequestedDebugpoints.status\n\n</td><td>\n\nResult of the instruction to add, delete, or update a specific breakpoint or logpoint.\n\n Possible values:\n\n-   failure\n-   ignored\n-   success\n\n A request to add, delete, or update a debug point is ignored in the following situations:\n\n-   It requests to delete a breakpoint or logpoint that doesn't exist.\n-   It requests to add a breakpoint or logpoint identical to one that already exists.\n\n Data type: String\n\n</td></tr><tr><td>\n\nrequestedDebugpoints.lineNumber\n\n</td><td>\n\nLine number in the server-side script specifying where the breakpoint or logpoint was added, deleted, or updated.Data type: Number\n\n</td></tr><tr><td>\n\nrequestedDebugpoints.debugpointType\n\n</td><td>\n\nType of debug point added, deleted, or updated.\n\n Possible values:\n\n-   breakpoint\n-   logpoint\n\n Data type: String\n\n</td></tr><tr><td>\n\nstatus\n\n</td><td>\n\nResult of the overall action. The status code for the HTTP call.Data type: Number\n\n</td></tr></tbody>\n</table>### cURL request\n\nThis example adds a conditional breakpoint at line 12 in the script.\n\n```\ncurl \"https://instance.servicenow.com/api/now/js/debugpoints/process\" \\\n--request POST \\\n--header \"Accept:application/json\" \\\n--header \"Content-Type:application/json\" \\\n--data “[\n{\n\\\"tableName\\\": \\\"sys_script_include\\\",\n\\\"scriptId\\\": \\\"d65f78c40a0a0b6900196656f35913d3\\\",\n\\\"fieldname\\\": \\\"script\\\",\n\\\"lineNumber\\\": 12,\n\\\"evaluationString\\\": \\\"a == false\\\",\n\\\"debugpointType\\\": \\\"breakpoint\\\",\n\\\"operation\\\": \\\"add\\\"\n}\n]” \\\n--user 'username':'password'\n```\n\n```\n{\n  \"result\": {\n    \"requestedDebugpoints\": [\n      {\n        \"scriptId\": \"d65f78c40a0a0b6900196656f35913d3\",\n        \"evaluationString\": \"a == false\",\n        \"operation\": \"add\",\n        \"tableName\": \"sys_script_include\",\n        \"fieldName\": \"script\",\n        \"status\": \"success\",\n        \"lineNumber\": 12,\n        \"debugpointType\": \"breakpoint\"\n      }\n    ],\n    \"status\": 200\n  }\n}\n\n```\n\n"}}