Updated on 2022-02-24 GMT+08:00

Performing Single-Step Debugging

To view requests sent by applications and responses from the IoT platform in a more intuitive manner, use the breakpoint debugging method of Eclipse. If you use the Postman test interface, see Using Postman to Test IoT Platform APIs.

  1. Set a breakpoint at the code where HTTP or HTTPS messages are sent.

    For example, set three breakpoints for the executeHttpRequest method in the sample code HttpsUtil.java. (Set the breakpoints according to the actual situation of your code.)

    Figure 1 Setting a breakpoint

  2. Right-click the class to be debugged based on the project type, for example, Authentication.java, and choose Debug As > Java Application.
  3. After the program stops running at the breakpoint, click Step Over to perform single-step debugging.

    You can view the content of the corresponding variable in the Variables window, such as the sent messages and the response messages of the IoT platform.

    Figure 2 Performing single-step debugging

  4. Expand the request variable in the Variables window to view the content of the requests.

    When the request variable is selected, the URLs of the requests sent by the applications are displayed in the content area in the lower part of the pane, and the content the requests is displayed in the entity area.
    Figure 3 Expanding the request variable
    The application ID (appId) and application key (secret) are contained in the content field and are represented by decimal ASCII codes. You need to convert them into letters and symbols according to the ASCII code table.
    Figure 4 Viewing the content field

  5. Expand the response variable in the Variables window to view the content of the responses.

    Figure 5 Expanding the response variable
    NOTE:

    In the code example, all classes other than Authentication.java call the Auth API in the first step. Therefore, when performing single-step debugging on a class other than Authentication.java, view the variable content when the program runs for the second time to the position where the breakpoint is set.