AMT Help Files

Debugging Provided REST API

Generating Provided REST API for debug

Debugging an AMT Provided REST API firstly starts with the same steps as any other AMT object, the generation of the Provided REST API in either private or public debug mode.
See Generating for debug.

Supporting AMT objects, such as global performable routines, can also be generated in debug mode to help the debugging process. 

Before the debugging can be started however, extra parameters in the appsettings.json file must be enabled to make the Debug parameters of the Provided REST API visible.

 

When debugging a Provided REST API, it is recommended to change the timeout settings to allow for more time while debugging.
The timeout settings can be adjusted in the Control Center > System Configuration > Batch and Forms > REST API Providers.

 

appsettings.json

Open the appsettings.json file of the Provided REST API, this file is located in the folder <Appication>\Binaries\Common\RestApiProvider\<Provided REST API>.

Locate or add the "EnableParams" key and set it to true:

"EnableParams": true,

Then save and close the json file.

This setting will add three query parameters to both of the two logon methods. I.e. AmtLogon and WinLogon.

After changing settings in the appsettings.json file, the IIS Application Pool containing the Provided REST API must be recycled/restarted to read the changed settings.

 

Setting up the debugger

The AMT Debugger is set up the normal way and should be connected to an Application Manager or Application Server. See Setting up the debugger.

In the case of an environment with multiple Application Servers, it is important to connect the AMT Debugger to the same Application Server as the provided REST API is using.

Once connected to the correct Application Server, the Provided REST API object can be opened from the 'Object Explorer' window. Inside the Provided REST API object the desired break points, watches etc. can be set in the same manner as other AMT objects. See Debugger Interface.

 

Start Debugging

Once the AMT debugger is connected, breakpoints, watches etc. have been set. The debug process can be started. Unlike forms and reports this can not be triggered from inside the AMT debugger but must be initiated from a call to the provided REST API. (If enabled the Swagger UI can be used for instance.)

The call to one of the two logon methods must be made with the 'DebugMode' query parameter set to true.

The user using the AMT debugger client must be the same as the user in the logon method. When using windows authentication (WinLogon) this is often already the case, for cookie authentication (AmtLogon) this can be a different user. In which same the 'UserName' query parameter must be passed with the name of the user using the AMT debugger client.

The 'StationName' query parameter can also be passed to aid in the debug process when needed.

Example of an AmtLogon call with debug mode enabled and the user "DBG_USER" impersonated:

curl -X 'POST' \
'http://AmtDev.example.com/AMT/RestAPICM/Amt/AmtLogon?UserName=DBG_USER&DebugMode=true' \
-H 'accept: */*' \
-H 'Content-Type: multipart/form-data' \
-F 'UserName=AmtUser1' \
-F 'Password=Password123!'

 

Once the correct user is logged on with DebugMode enabled, calls to other methods of the provided REST API can be made which will trigger the AMT debugger.

From that point on, the normal AMT debugger commands can be used to debug the methods of the Provided REST API. See Debugger Commands.

 

Relevant page

Debugging