How to Write Information via SUST API

v1.01. Written by: Zhang Cheng.

This system uses asymmetric encryption for data integration. RSA public and private keys are generated with OpenSSL and used for data encryption and decryption. The integration process is as follows.

1. Obtain the Public Key for Write API

Register in the student affairs system. The key is provided by the Information Section of the Student Affairs Department. You need to provide the application name, application URL, and required API names. The application URL is not required during testing, but it is required for production launch.

2. Obtain the Application ID for Write API

After application registration is complete, an application number is generated at the same time. This value is used as ClientId.

3. Write API Integration Endpoint

The unified write API endpoint is:

  • Public network: domain/openapi/apiput/index

  • Private network: http://ip/xgb/index.php/openapi/apiinput/index

Request method: POST.

4. Write API Integration Method

Request parameters:

Parameter

Required

Description

ClientId

Yes

Application ID

AuthStr

Yes

Permission and timestamp verification code. See below.

AuthStr is a global authentication variable. It contains information such as the API name and timestamp verification. Generate it as follows:

  • Build the string as ApiName&timestamp.

  • Encrypt the string with the public key.

  • Run base64_encode on the encrypted value before transmission.

Example: to access the student list, the API name is StudentList, and the current timestamp is assumed to be 1730189433.

  1. Build the string: StudentList&1730189433.

  2. Encrypt with the public key: sadsadjsldjljflcvjlcvjlxcvjlxcvjlxcvj.

  3. Encode with base64_encode: fgldjflgjfdlgjdljasdhkjasdhas.

  4. Access:

openapi/api/index?ClientId=xxxx&AuthStr=fgldjflgjfdlgjdljasdhkjasdhas&other_parameters

The server verifies permissions and whether the timestamp has expired. If an error occurs, the corresponding error message is displayed.

5. Data Insertion API

5.1 Insert Student Leave Data

Note: use the write API endpoint for this operation.

API name: addLeave.

Data format:

{
  "UUID": "550e8400e29b41d4a716446655440000",
  "student_id": "202310001",
  "student_name": "Alex Lee",
  "leave_type": 2,
  "begin_time": "2023-10-15 08:00:00",
  "end_time": "2023-10-17 18:00:00",
  "leave_reason": "Family matter requiring a three-day leave.",
  "apply_time": "2023-10-14 14:30:00",
  "back_time": null,
  "leave_status": 1,
  "back_status": 0,
  "is_deleted": 0
}

UUID is the system unique code and is used for updates. To delete leave data, update the deletion flag.

Default leave types: 1 for personal leave, 2 for sick leave.

leave_status defaults to 1. back_status indicates leave-cancellation status (0 or 1). When back_time is empty, pass null instead of an empty string.

Response:

{
  "code": 200,
  "msg": "Record added successfully",
  "data": {
    "UUID": "550e8400e29b41d4a716446655440003",
    "student_id": "202310001",
    "student_name": "Alex Lee",
    "leave_type": 2,
    "begin_time": "2023-10-15 08:00:00",
    "end_time": "2023-10-17 18:00:00",
    "leave_reason": "Family matter requiring a three-day leave.",
    "apply_time": "2023-10-14 14:30:00",
    "back_time": null,
    "leave_status": 1,
    "back_status": 0,
    "is_deleted": 0,
    "update_time": "2025-10-14 11:12:53"
  }
}

Add and update operations use the same API and API name. The system determines whether to create or update by the unique UUID value.

When is_deleted is 1, the operation is a delete action.

Data update example:

{
  "UUID": "550e8400e29b41d4a716446655440001",
  "student_id": "202310001",
  "student_name": "Alex Lee",
  "leave_type": 2,
  "begin_time": "2023-10-15 08:00:00",
  "end_time": "2023-10-17 18:00:00",
  "leave_reason": "Family matter requiring a three-day leave.",
  "apply_time": "2023-10-14 14:30:00",
  "back_time": null,
  "leave_status": 1,
  "back_status": 0,
  "is_deleted": 0
}

Data update response:

{
  "code": 200,
  "msg": "Record added successfully",
  "data": {
    "UUID": "550e8400e29b41d4a716446655440001",
    "student_id": "202310001",
    "student_name": "Alex Lee",
    "leave_type": 2,
    "begin_time": "2023-10-15 08:00:00",
    "end_time": "2023-10-17 18:00:00",
    "leave_reason": "Family matter requiring a three-day leave.",
    "apply_time": "2023-10-14 14:30:00",
    "back_time": null,
    "leave_status": 1,
    "back_status": 0,
    "is_deleted": 0,
    "update_time": "2025-10-14 11:12:42"
  }
}