MobileApp

Function: create_template Type: API Endpoint (POST)

Purpose: Creates a new template in the database for the provided template data. It generates a unique template code, checks for existing templates, and adds the new template and associated pages to the database.

URL: POST /templates/create

Headers:

  • Customer_Key (str, required): Encoded customer key for authorization.

Request Body:

  • template_data (TemplateDataRequest): The data for the template, including application code, report code, template name, and other details.

Process:

  1. Decode and validate the Customer_Key.
  2. Iterate through each item in template_data.
  3. Generate a unique template code.
  4. Check if a template already exists for the report code.
  5. Create a new template and add it to the database.
  6. If is_page is True, create associated pages.
  7. Update the serial number for the template code.

Response:

  • Returns a success message if the template is created successfully.
  • Returns error messages if the customer key is invalid, a template already exists, or a page already exists.

Error Handling:

  • Catches exceptions and returns a 500 error with the exception message.
post/api/MobileApp/templates/create

Request

Headers

Customer-Keystring required

Request body

Response

Successful Response

unknown required

Changes