Threads Resource (Debugger API 2.0)

Summary

Http Method Resource Description
GET /threads Returns the script threads in the script engine. A script thread is either 'running' or 'halted'. If the script thread is halted, the script thread contains a call stack of stack frames representing the execution path. The stack frame at index [0] represents the current location of the execution path. Both the script thread identifier and a stack frame index are required for evaluating expressions and viewing object state.
POST /threads/reset Directs the debugger to reset the timeout counter for all halted script threads. Each script thread can sleep up to 60 seconds before the debugger will terminate the thread. This action resets the timeout counter allowing a thread to halt for another 60 seconds. Note that if a script thread times out, the script engine throws a ScriptDebuggerTerminate error in the script that was halted.
GET /threads/{thread_id} Returns the script thread specified by the thread identifier. A script thread is either 'running' or 'halted'. If the script thread is halted, the script thread contains a call stack of stack frames representing the execution path. The stack frame at index [0] represents the current location of the execution path. Both the script thread identifier and a stack frame index are required for evaluating expressions and viewing object state. If the script thread cannot be located, this action throws a ScriptThreadNotFoundException.
GET /threads/{thread_id}/frames/{frame_index}/eval Evaluates an expression in the context of the specified thread and frame. Each script thread contains a call stack of stack frames representing the execution path. The stack frame at index [0] represents the current location of the execution path. You can also use other frame indices for expression evaluation outside the current location. If the script thread cannot be located, this action throws a ScriptThreadNotFoundException. If the frame index is not valid, this action throws an InvalidFrameIndexException.
GET /threads/{thread_id}/frames/{frame_index}/members Returns the members of the object path in the context of the specified thread and frame. If the object path is not specified, returns all members of the specified thread and frame. Each script thread contains a call stack of stack frames representing the execution path. The stack frame at index [0] represents the current location of the execution path. You can also use other frame indices for viewing object state outside the current location. If the script thread cannot be located, this action throws a ScriptThreadNotFoundException. If the frame index is not valid, this action throws an InvalidFrameIndexException.
GET /threads/{thread_id}/frames/{frame_index}/variables Returns the variables in the context of the specified thread and frame scope and all inclosing scopes. Each script thread contains a call stack of stack frames representing the execution path. The stack frame at index [0] represents the current location of the execution path. You can also use other frame indices for viewing object state outside the current location. If the script thread cannot be located, this action throws a ScriptThreadNotFoundException. If the frame index is not valid, this action throws an InvalidFrameIndexException.
POST /threads/{thread_id}/into Directs the script thread to step into the function at the current thread location. If the current location is not a function, this action steps to the next line in the script. If there are no other lines in the script, the script completes. If the script thread cannot be located, this action throws a ScriptThreadNotFoundException.
POST /threads/{thread_id}/out Directs the script thread to step out of the current thread location and to return to the parent in the call stack. If there is no parent in the call stack, this action directs the script thread to resume. If the script thread cannot be located, this action throws a ScriptThreadNotFoundException.
POST /threads/{thread_id}/over Directs the script thread to step over the current thread location to the next line in the script. If the current location is at the end of a script function, this action directs the script thread to resume. If the script thread cannot be located, this action throws a ScriptThreadNotFoundException.
POST /threads/{thread_id}/resume Directs the script thread to resume the execution of the script. Depending on the script location and breakpoints, calling resume can result in the thread stopping at another breakpoint. If the script thread cannot be located, this action throws a ScriptThreadNotFoundException.
POST /threads/{thread_id}/stop Directs the script thread to stop execution. This action directs the script engine to throw a ScriptDebuggerTerminate error in the script that was halted. If the script thread cannot be located, this action throws a ScriptThreadNotFoundException.

Get Script Threads Document.

Returns the script threads in the script engine. A script thread is either 'running' or 'halted'. If the script thread is halted, the script thread contains a call stack of stack frames representing the execution path. The stack frame at index [0] represents the current location of the execution path. Both the script thread identifier and a stack frame index are required for evaluating expressions and viewing object state.

Url

GET http://hostname:port/dw/debugger/v2_0/threads

Formats

json, xml

Authentication

Name Description
None No authentication.

Response Document

ScriptThreads

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
400 ClientIdRequiredException   Indicates that the request did not contain a client identifier.
401 NotAuthorizedException   Indicates that the specified user is not authorized.
412 DebuggerDisabledException   Indicates that the debugger Client resource has not been created.

Sample

REQUEST:
GET /s/-/dw/debugger/v1_0/threads HTTP/1.1
Authorization: Basic YWRtaW46RGVtYW5kd2FyZTEh
x-dw-client-id: DebuggerTest
Content-Type: application/json
Content-Length: 0

# in case of success:
 
RESPONSE:
HTTP/1.1 200 OK
{
  "_v":"2.0",
  "script_threads":[
  {
    "call_stack":[
    {
      "index":0,"location":
      {
        "function_name":"first()",
        "line_number":25,
        "script_path":"/app_storefront_controllers/cartridge/scripts/models/CartModel.js"
      }
    },
    {
      "index":1,
      "location":
      {
        "function_name":"execute()",
        "line_number":12,
        "script_path":"/app_storefront_controllers/cartridge/controllers/Cart.js"
      }
    }
  ],
  "id":2,"status":"halted"
  }
 ]
}

in case of error:

RESPONSE:
HTTP/1.1 401 Unauthorized
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "fault":
    {
      "type":"NotAuthorizedException",
      "message":"You are not authorized to use the Script Debugger."
    }
}

RESPONSE:
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "fault":
  {
    "type":"ClientIdRequiredException",
    "message":"You must have a client identifier in the request header using the key 'x-dw-client-id'."
  }
}

Reset

Directs the debugger to reset the timeout counter for all halted script threads. Each script thread can sleep up to 60 seconds before the debugger will terminate the thread. This action resets the timeout counter allowing a thread to halt for another 60 seconds. Note that if a script thread times out, the script engine throws a ScriptDebuggerTerminate error in the script that was halted.

Url

POST http://hostname:port/dw/debugger/v2_0/threads/reset

Formats

json, xml

Authentication

Name Description
None No authentication.

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
400 ClientIdRequiredException   Indicates that the request did not contain a client identifier.
401 NotAuthorizedException   Indicates that the specified user is not authorized.
412 DebuggerDisabledException   Indicates that the debugger Client resource has not been created.

Sample

REQUEST:
POST /s/-/dw/debugger/v1_0/threads/reset HTTP/1.1
Authorization: Basic YWRtaW46RGVtYW5kd2FyZTEh
x-dw-client-id: DebuggerTest
Content-Type: application/json
Content-Length: 0
 
# in case of success:
 
RESPONSE:
HTTP/1.1 204 OK

# in case of failure:
 
RESPONSE
HTTP/1.1 401 Unauthorized
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "fault":
    {
      "type":"NotAuthorizedException",
      "message":"You are not authorized to use the Script Debugger."
    }
}

RESPONSE
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "fault":
  {
    "type":"ClientIdRequiredException",
    "message":"You must have a client identifier in the request header using the key 'x-dw-client-id'."
  }
}

Get Script Thread

Returns the script thread specified by the thread identifier. A script thread is either 'running' or 'halted'. If the script thread is halted, the script thread contains a call stack of stack frames representing the execution path. The stack frame at index [0] represents the current location of the execution path. Both the script thread identifier and a stack frame index are required for evaluating expressions and viewing object state. If the script thread cannot be located, this action throws a ScriptThreadNotFoundException.

Url

GET http://hostname:port/dw/debugger/v2_0/threads/{thread_id}

Formats

json, xml

Authentication

Name Description
None No authentication.

Response Document

ScriptThread

Path Parameters

Parameter Type Description Constraints
thread_id Integer the thread identifier. minLength=1

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
400 ClientIdRequiredException   Indicates that the request did not contain a client identifier.
401 NotAuthorizedException   Indicates that the specified user is not authorized.
404 ScriptThreadNotFoundException

threadId (Integer)

Indicates that the requested thread could not be found.
412 DebuggerDisabledException   Indicates that the debugger Client resource has not been created.

Sample

REQUEST:
GET /s/-/dw/debugger/v1_0/threads/2 HTTP/1.1
Authorization: Basic YWRtaW46RGVtYW5kd2FyZTEh
x-dw-client-id: DebuggerTest
Content-Type: application/json
Content-Length: 0

# in case of success:
 
RESPONSE:
HTTP/1.1 200 OK
{
  "_v":"2.0",
    "call_stack":[
    {
      "index":0,"location":
      {
        "function_name":"first()",
        "line_number":25,
        "script_path":"/app_storefront_controllers/cartridge/scripts/models/CartModel.js"
      }
    },
    {
      "index":1,
      "location":
      {
        "function_name":"execute()",
        "line_number":12,
        "script_path":"/app_storefront_controllers/cartridge/controllers/Cart.js"
      }
    }
  ],    
  "id":2,
  "status":"halted"
}

# in case of failure:
 
RESPONSE:
HTTP/1.1 404 Requested resource not found
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "type":"ScriptThreadNotFoundException",
  "message":"Could not find Script Thread for identifier '1'."
}

RESPONSE:
HTTP/1.1 401 Unauthorized
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "fault":
    {
      "type":"NotAuthorizedException",
      "message":"You are not authorized to use the Script Debugger."
    }
}

RESPONSE:
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "fault":
  {
    "type":"ClientIdRequiredException",
    "message":"You must have a client identifier in the request header using the key 'x-dw-client-id'."
  }
}


Evaluate Expression

Evaluates an expression in the context of the specified thread and frame. Each script thread contains a call stack of stack frames representing the execution path. The stack frame at index [0] represents the current location of the execution path. You can also use other frame indices for expression evaluation outside the current location. If the script thread cannot be located, this action throws a ScriptThreadNotFoundException. If the frame index is not valid, this action throws an InvalidFrameIndexException.

Url

GET http://hostname:port/dw/debugger/v2_0/threads/{thread_id}/frames/{frame_index}/eval?expr={String}

Formats

json, xml

Authentication

Name Description
None No authentication.

Response Document

EvalResult

Path Parameters

Parameter Type Description Constraints
frame_index Integer the frame index in the thread call stack. minLength=1
thread_id Integer the thread identifier. minLength=1

Query Parameters

Parameter Type Description Constraints
expr String the expression to evaluate.  

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
400 ClientIdRequiredException   Indicates that the request did not contain a client identifier.
400 InvalidFrameIndexException

frameIndex (Integer)

threadId (Integer)

Indicates that the frame index is not valid for the script thread.
401 NotAuthorizedException   Indicates that the specified user is not authorized.
404 ScriptThreadNotFoundException

threadId (Integer)

Indicates that the script thread can not be found.
412 DebuggerDisabledException   Indicates that the Client resource has not been created.

Sample

REQUEST:
GET /s/-/dw/debugger/v1_0/threads/1/frames/0/eval?expr=calculate()
Authorization: Basic YWRtaW46RGVtYW5kd2FyZTEh
x-dw-client-id: DebuggerTest
Content-Type: application/json
Content-Length: 0

RESPONSE:
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "expression":"calculate()",
  "result":100
}

# in case of failure:
 
RESPONSE:
HTTP/1.1 404 Requested resource not found
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "type":"ScriptThreadNotFoundException",
  "message":"Could not find Script Thread for identifier '1'."
}

RESPONSE:
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "fault":
  {
    "type":"InvalidFrameIndexException",
    "message":"Frame index '2' does not exist for Script Thread '2'."
  }
}

RESPONSE
HTTP/1.1 401 Unauthorized
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "fault":
    {
      "type":"NotAuthorizedException",
      "message":"You are not authorized to use the Script Debugger."
    }
}

RESPONSE
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "fault":
  {
    "type":"ClientIdRequiredException",
    "message":"You must have a client identifier in the request header using the key 'x-dw-client-id'."
  }
}


Get Object Members

Returns the members of the object path in the context of the specified thread and frame. If the object path is not specified, returns all members of the specified thread and frame. Each script thread contains a call stack of stack frames representing the execution path. The stack frame at index [0] represents the current location of the execution path. You can also use other frame indices for viewing object state outside the current location. If the script thread cannot be located, this action throws a ScriptThreadNotFoundException. If the frame index is not valid, this action throws an InvalidFrameIndexException.

Url

GET http://hostname:port/dw/debugger/v2_0/threads/{thread_id}/frames/{frame_index}/members?object_path={String}&start={Integer}&count={Integer}

Formats

json, xml

Authentication

Name Description
None No authentication.

Response Document

ObjectMembers

Path Parameters

Parameter Type Description Constraints
frame_index Integer the frame index in the thread's call stack. minLength=1
thread_id Integer the thread identifier. minLength=1

Query Parameters

Parameter Type Description Constraints
count Integer An integer indicating the number of items to return. If not set, the default is 200. maxIntegerValue=2147483647, minIntegerValue=1
object_path String An optional dot-delimited path. The path represents an object in the thread's call stack, where each segment in the path represents a descendant of the object. If this parameter is not specified, all objects in the thread's frame are returned.  
start Integer An integer indicating the start location in the result set to return. If not set, the default is 0. minIntegerValue=0

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
400 ClientIdRequiredException   Indicates that the request did not contain a client identifier.
400 InvalidFrameIndexException

frameIndex (Integer)

threadId (Integer)

Indicates that the frame index is not valid for the script thread.
401 NotAuthorizedException   Indicates that the specified user is not authorized.
404 ScriptThreadNotFoundException

threadId (Integer)

Indicates that the script thread can not be found.
412 DebuggerDisabledException   Indicates that the Client resource has not been created.

Sample

REQUEST:
GET /s/-/dw/debugger/v1_0/threads/1/frames/0/members?object_path=basket.productLineItems
Authorization: Basic YWRtaW46RGVtYW5kd2FyZTEh
x-dw-client-id: DebuggerTest
Content-Type: application/json
Content-Length: 0

RESPONSE:
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "object_members":
  [
    {
      "name":"[0]",
      "parent":"basket",
      "type":"dw.order.ProductLineItem",
      "value":"[ProductLineItem uuid=bcDfLaOacbNVMaaadoDBceQDFh]"
    },
    {
      "name":"[1]",
      "parent":"basket",
      "type":"dw.order.ProductLineItem",
      "value":"[ProductLineItem uuid=bcLNbaOacbhiUaaadokBgeQDFh]"
    }
  ]
}

# in case of failure:
 
RESPONSE:
HTTP/1.1 404 Requested resource not found
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "type":"ScriptThreadNotFoundException",
  "message":"Could not find Script Thread for identifier '1'."
}

RESPONSE:
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "fault":
  {
    "type":"InvalidFrameIndexException",
    "message":"Frame index '2' does not exist for Script Thread '2'."
  }
}

RESPONSE
HTTP/1.1 401 Unauthorized
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "fault":
    {
      "type":"NotAuthorizedException",
      "message":"You are not authorized to use the Script Debugger."
    }
}

RESPONSE
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "fault":
  {
    "type":"ClientIdRequiredException",
    "message":"You must have a client identifier in the request header using the key 'x-dw-client-id'."
  }
}


Get Variables

Returns the variables in the context of the specified thread and frame scope and all inclosing scopes. Each script thread contains a call stack of stack frames representing the execution path. The stack frame at index [0] represents the current location of the execution path. You can also use other frame indices for viewing object state outside the current location. If the script thread cannot be located, this action throws a ScriptThreadNotFoundException. If the frame index is not valid, this action throws an InvalidFrameIndexException.

Url

GET http://hostname:port/dw/debugger/v2_0/threads/{thread_id}/frames/{frame_index}/variables

Formats

json, xml

Authentication

Name Description
None No authentication.

Response Document

ObjectMembers

Path Parameters

Parameter Type Description Constraints
frame_index Integer the frame index in the thread's call stack. minLength=1
thread_id Integer the thread identifier. minLength=1

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
400 ClientIdRequiredException   Indicates that the request did not contain a client identifier.
400 InvalidFrameIndexException

frameIndex (Integer)

threadId (Integer)

Indicates that the frame index is not valid for the script thread.
401 NotAuthorizedException   Indicates that the specified user is not authorized.
404 ScriptThreadNotFoundException

threadId (Integer)

Indicates that the script thread can not be found.
412 DebuggerDisabledException   Indicates that the Client resource has not been created.

Sample

REQUEST:
GET /s/-/dw/debugger/v1_0/threads/1/frames/0/variables
Authorization: Basic YWRtaW46RGVtYW5kd2FyZTEh
x-dw-client-id: DebuggerTest
Content-Type: application/json
Content-Length: 0

RESPONSE:
HTTP/1.1 200 OK
{
    "_v": "2.0",
    "count": 14,
    "object_members": [
        {
            "name": "arguments",
            "parent": "",
            "scope": "local",
            "type": "Object",
            "value": "[object Arguments]"
        },
        {
            "name": "arguments",
            "parent": "",
            "scope": "closure",
            "type": "Object",
            "value": "[object Arguments]"
        },
        {
            "name": "requiredFunction",
            "parent": "",
            "scope": "global",
            "type": "Function",
            "value": "\nfunction requiredFunction() {\n    var dwUtil = require(\"dw/util\");\n    var CustomerMgr = require(\"dw/customer/CustomerMgr\");\n    return true;\n}\n"
        }
    ],
    "start": 0,
    "total": 4
}

# in case of failure:
 
RESPONSE:
HTTP/1.1 404 Requested resource not found
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "type":"ScriptThreadNotFoundException",
  "message":"Could not find Script Thread for identifier '1'."
}

RESPONSE:
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "fault":
  {
    "type":"InvalidFrameIndexException",
    "message":"Frame index '2' does not exist for Script Thread '2'."
  }
}

RESPONSE
HTTP/1.1 401 Unauthorized
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "fault":
    {
      "type":"NotAuthorizedException",
      "message":"You are not authorized to use the Script Debugger."
    }
}

RESPONSE
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "fault":
  {
    "type":"ClientIdRequiredException",
    "message":"You must have a client identifier in the request header using the key 'x-dw-client-id'."
  }
}

Step Into

Directs the script thread to step into the function at the current thread location. If the current location is not a function, this action steps to the next line in the script. If there are no other lines in the script, the script completes. If the script thread cannot be located, this action throws a ScriptThreadNotFoundException.

Url

POST http://hostname:port/dw/debugger/v2_0/threads/{thread_id}/into

Formats

json, xml

Authentication

Name Description
None No authentication.

Response Document

ScriptThread

Path Parameters

Parameter Type Description Constraints
thread_id Integer the thread identifier. minLength=1

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
400 ClientIdRequiredException   Indicates that the request did not contain a client identifier.
401 NotAuthorizedException   Indicates that the specified user is not authorized.
404 ScriptThreadNotFoundException

threadId (Integer)

Indicates that the requested thread could not be found.
412 DebuggerDisabledException   Indicates that the debugger Client resource has not been created.

Sample

REQUEST:
POST /s/-/dw/debugger/v1_0/threads/2/into HTTP/1.1
Authorization: Basic YWRtaW46RGVtYW5kd2FyZTEh
x-dw-client-id: DebuggerTest
Content-Type: application/json
Content-Length: 0
 
# in case of success:
 
RESPONSE:
HTTP/1.1 200 OK
{
    "_v": "2.0",
    "call_stack": [
        {
            "index": 0,
            "location": {
                "function_name": "start()",
                "line_number": 50,
                "script_path": "/app_storefront_controllers/cartridge/controllers/Cart.js"
            }
        }
    ],
    "id": 4,
    "status": "halted"
}


# in case of failure:
 
RESPONSE:
HTTP/1.1 404 Requested resource not found
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "type":"ScriptThreadNotFoundException",
  "message":"Could not find Script Thread for identifier '1'."
}

RESPONSE:
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "fault":
  {
    "type":"InvalidFrameIndexException",
    "message":"Frame index '2' does not exist for Script Thread '2'."
  }
}
 
RESPONSE
HTTP/1.1 401 Unauthorized
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "fault":
    {
      "type":"NotAuthorizedException",
      "message":"You are not authorized to use the Script Debugger."
    }
}

RESPONSE
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "fault":
  {
    "type":"ClientIdRequiredException",
    "message":"You must have a client identifier in the request header using the key 'x-dw-client-id'."
  }
}

Step Out

Directs the script thread to step out of the current thread location and to return to the parent in the call stack. If there is no parent in the call stack, this action directs the script thread to resume. If the script thread cannot be located, this action throws a ScriptThreadNotFoundException.

Url

POST http://hostname:port/dw/debugger/v2_0/threads/{thread_id}/out

Formats

json, xml

Authentication

Name Description
None No authentication.

Response Document

ScriptThread

Path Parameters

Parameter Type Description Constraints
thread_id Integer the thread identifier. minLength=1

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
400 ClientIdRequiredException   Indicates that the request did not contain a client identifier.
401 NotAuthorizedException   Indicates that the specified user is not authorized.
404 ScriptThreadNotFoundException

threadId (Integer)

Indicates that the requested thread could not be found.
412 DebuggerDisabledException   Indicates that the debugger Client resource has not been created.

Sample

REQUEST:
POST /s/-/dw/debugger/v1_0/threads/2/out HTTP/1.1
Authorization: Basic YWRtaW46RGVtYW5kd2FyZTEh
x-dw-client-id: DebuggerTest
Content-Type: application/json
Content-Length: 0
 
# in case of success:
 
RESPONSE:
HTTP/1.1 200 OK
{
    "_v": "2.0",
    "call_stack": [
        {
            "index": 0,
            "location": {
                "function_name": "start()",
                "line_number": 50,
                "script_path": "/app_storefront_controllers/cartridge/controllers/Cart.js"
            }
        }
    ],
    "id": 4,
    "status": "halted"
}

# in case of failure:
 
RESPONSE:
HTTP/1.1 404 Requested resource not found
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "type":"ScriptThreadNotFoundException",
  "message":"Could not find Script Thread for identifier '1'."
}

RESPONSE:
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "fault":
  {
    "type":"InvalidFrameIndexException",
    "message":"Frame index '2' does not exist for Script Thread '2'."
  }
}
 
RESPONSE
HTTP/1.1 401 Unauthorized
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "fault":
    {
      "type":"NotAuthorizedException",
      "message":"You are not authorized to use the Script Debugger."
    }
}

RESPONSE
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "fault":
  {
    "type":"ClientIdRequiredException",
    "message":"You must have a client identifier in the request header using the key 'x-dw-client-id'."
  }
}

Step Over

Directs the script thread to step over the current thread location to the next line in the script. If the current location is at the end of a script function, this action directs the script thread to resume. If the script thread cannot be located, this action throws a ScriptThreadNotFoundException.

Url

POST http://hostname:port/dw/debugger/v2_0/threads/{thread_id}/over

Formats

json, xml

Authentication

Name Description
None No authentication.

Response Document

ScriptThread

Path Parameters

Parameter Type Description Constraints
thread_id Integer the thread identifier. minLength=1

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
400 ClientIdRequiredException   Indicates that the request did not contain a client identifier.
401 NotAuthorizedException   Indicates that the specified user is not authorized.
404 ScriptThreadNotFoundException

threadId (Integer)

Indicates that the requested thread could not be found.
412 DebuggerDisabledException   Indicates that the debugger Client resource has not been created.

Sample

REQUEST:
POST /s/-/dw/debugger/v1_0/threads/2/over HTTP/1.1
Authorization: Basic YWRtaW46RGVtYW5kd2FyZTEh
x-dw-client-id: DebuggerTest
Content-Type: application/json
Content-Length: 0
 
# in case of success:
 
RESPONSE:
HTTP/1.1 200 OK
{
    "_v": "2.0",
    "call_stack": [
        {
            "index": 0,
            "location": {
                "function_name": "start()",
                "line_number": 50,
                "script_path": "/app_storefront_controllers/cartridge/controllers/Cart.js"
            }
        }
    ],
    "id": 4,
    "status": "halted"
}

# in case of failure:
 
RESPONSE:
HTTP/1.1 404 Requested resource not found
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "type":"ScriptThreadNotFoundException",
  "message":"Could not find Script Thread for identifier '1'."
}

RESPONSE:
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "fault":
  {
    "type":"InvalidFrameIndexException",
    "message":"Frame index '2' does not exist for Script Thread '2'."
  }
}
 
RESPONSE
HTTP/1.1 401 Unauthorized
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "fault":
    {
      "type":"NotAuthorizedException",
      "message":"You are not authorized to use the Script Debugger."
    }
}

RESPONSE
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "fault":
  {
    "type":"ClientIdRequiredException",
    "message":"You must have a client identifier in the request header using the key 'x-dw-client-id'."
  }
}

Resume

Directs the script thread to resume the execution of the script. Depending on the script location and breakpoints, calling resume can result in the thread stopping at another breakpoint. If the script thread cannot be located, this action throws a ScriptThreadNotFoundException.

Url

POST http://hostname:port/dw/debugger/v2_0/threads/{thread_id}/resume

Formats

json, xml

Authentication

Name Description
None No authentication.

Response Document

ScriptThread

Path Parameters

Parameter Type Description Constraints
thread_id Integer the thread identifier. minLength=1

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
400 ClientIdRequiredException   Indicates that the request did not contain a client identifier.
401 NotAuthorizedException   Indicates that the specified user is not authorized.
404 ScriptThreadNotFoundException

threadId (Integer)

Indicates that the requested thread could not be found.
412 DebuggerDisabledException   Indicates that the debugger Client resource has not been created.

Sample

REQUEST:
POST /s/-/dw/debugger/v1_0/threads/2/resume HTTP/1.1
Authorization: Basic YWRtaW46RGVtYW5kd2FyZTEh
x-dw-client-id: DebuggerTest
Content-Type: application/json
Content-Length: 0
 
# in case of success:
 
RESPONSE:
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
{
    "_v": "2.0",
    "id": 2,
    "status": "running"
}

# in case of failure:
 
RESPONSE:
HTTP/1.1 404 Requested resource not found
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "type":"ScriptThreadNotFoundException",
  "message":"Could not find Script Thread for identifier '1'."
}

RESPONSE:
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "fault":
  {
    "type":"InvalidFrameIndexException",
    "message":"Frame index '2' does not exist for Script Thread '2'."
  }
}
 
RESPONSE
HTTP/1.1 401 Unauthorized
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "fault":
    {
      "type":"NotAuthorizedException",
      "message":"You are not authorized to use the Script Debugger."
    }
}

RESPONSE
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "fault":
  {
    "type":"ClientIdRequiredException",
    "message":"You must have a client identifier in the request header using the key 'x-dw-client-id'."
  }
}

Stop

Directs the script thread to stop execution. This action directs the script engine to throw a ScriptDebuggerTerminate error in the script that was halted. If the script thread cannot be located, this action throws a ScriptThreadNotFoundException.

Url

POST http://hostname:port/dw/debugger/v2_0/threads/{thread_id}/stop

Formats

json, xml

Authentication

Name Description
None No authentication.

Path Parameters

Parameter Type Description Constraints
thread_id Integer the thread identifier. minLength=1

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
400 ClientIdRequiredException   Indicates that the request did not contain a client identifier.
401 NotAuthorizedException   Indicates that the specified user is not authorized.
404 ScriptThreadNotFoundException

threadId (Integer)

Indicates that the requested thread could not be found.
412 DebuggerDisabledException   Indicates that the debugger Client resource has not been created.

Sample

REQUEST:
POST /s/-/dw/debugger/v1_0/threads/2/stop HTTP/1.1
Authorization: Basic YWRtaW46RGVtYW5kd2FyZTEh
x-dw-client-id: DebuggerTest
Content-Type: application/json
Content-Length: 0
 
# in case of success:
 
RESPONSE:
HTTP/1.1 204 OK

# in case of failure:
 
RESPONSE:
HTTP/1.1 404 Requested resource not found
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "type":"ScriptThreadNotFoundException",
  "message":"Could not find Script Thread for identifier '1'."
}

RESPONSE:
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "fault":
  {
    "type":"InvalidFrameIndexException",
    "message":"Frame index '2' does not exist for Script Thread '2'."
  }
}
 
RESPONSE
HTTP/1.1 401 Unauthorized
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "fault":
    {
      "type":"NotAuthorizedException",
      "message":"You are not authorized to use the Script Debugger."
    }
}

RESPONSE
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "fault":
  {
    "type":"ClientIdRequiredException",
    "message":"You must have a client identifier in the request header using the key 'x-dw-client-id'."
  }
}