MobileApp

Create Basic Details

Changed on

Function: create_basic_details

Type: API Endpoint (POST)

Purpose:
Creates a new template with the given details and saves the initial template details.

Endpoint:
POST /api/templates/create_basic_details

Request Headers:

  • Customer-Key (str, required): A base64 encoded string containing lscode and firmcode for the customer. This must be decoded for database access.

Request Body:

  • template_data (TemplateCreateRequest, required): Contains the template name, report code, format, email subject, email body, email CC and BCC, and status.

Response:

  • Returns a JSON object containing the newly created template code, template name, format, email subject, email body, email CC and BCC, and status.

Exceptions:

  • Handles exceptions related to invalid customer key format, missing idx for update/delete operations, and database errors, providing appropriate error messages.

Steps:

  1. Customer Key Decoding:
    Decodes the Customer_Key to extract the lscode and firmcode. Raises an error if the format is invalid.

  2. Input Validation:
    Validates the presence of template_name, report_code, format, email_subject, and email_body in the request body.

  3. Database Connection:
    Establishes a connection to the database using custCursorConnection.

  4. Template Creation:
    Creates a new template with the given details and saves the initial template details.

  5. Transaction Handling:
    Commits the transaction if all operations are successful, or rolls back in case of an error.

  6. Logging:
    Logs the API call with details of the operation.

  7. Response Construction:
    Returns a success message or error details based on the outcome of the operations.

post/api/MobileApp/templates/create_basic_details

Request

Headers

Customer-Keystring required

Request body

idstring nullable
statusboolean required
report_typeinteger
template_namestring required
app_codestring required
formatstring required
email_subjectstring required
email_ccstring[] nullable
email_bccstring[] nullable
email_bodystring nullable
storage_typeinteger
storage_configobject nullable
is_containerboolean nullable
file_pathstring nullable
file_namestring nullable
modified_bystring nullable
modified_onstring date-time

Response

Successful Response

unknown required

Changes