Skip to content
Ubaldo Porcheddu edited this page Jan 14, 2024 · 3 revisions

API Usage Guide

Overview

This guide outlines the steps to interact with the API, covering authentication, performing a search operation, creating a new translation, and saving the data in the "ejaTranslations" module.

Authentication

If you don't already have a Session, you can obtain one by sending a POST request to the authentication endpoint with a JSON payload containing the Action set to "login" and the Values field with the "username" and "password" key-value pairs.

Example JSON payload for login:

{
  "Action": "login",
  "Values": {
    "username": "your_username",
    "password": "your_password"
  }
}

Upon a successful login, the server will respond with a new session token.

Performing Search

After obtaining the session, perform a search in the "ejaTranslations" module. Construct a JSON payload with the following parameters:

  • Action: Set to "search" to indicate a search operation.
  • Session: The obtained session token.
  • ModuleName: Set to "ejaTranslations" to specify the module for the search.

Additional optional parameters for customization:

  • SearchLimit: Limit the number of results.
  • SearchOffset: Offset the results.
  • SearchOrder: Order the results by specific columns.

Example JSON payload for search:

{
  "Action": "search",
  "Session": "your_session_token",
  "ModuleName": "ejaTranslations",
  "SearchLimit": 10,
  "SearchOffset": 0,
  "SearchOrder": {
    "word": "ASC",
    "translation": "DESC"
  }
}

The server will respond with the search results in the "SearchRows" field.

Creating a New Translation

To create a new translation, use the Action set to "new". This will return a new ID that can be used to save the data.

Example JSON payload for creating a new translation:

{
  "Action": "new",
  "Session": "your_session_token",
  "ModuleName": "ejaTranslations"
}

The server will respond with a new ID.

Saving or Updating Data

Once you have the new ID, save the data by passing the new Values, the Session, and the Action set to "save."

Example JSON payload for saving data:

{
  "Action": "save",
  "Session": "your_session_token",
  "ModuleName": "ejaTranslations",
  "Id": "newly_generated_id",
  "Values": {
    "word": "test",
    "translation": "prova",
    "ejaLanguage": "it"
  }
}

Deleting Data

To delete data, pass the Action set to "delete," the ModuleName and the Id.

Example JSON payload for deleting data:

{
  "Action": "delete",
  "Session": "your_session_token",
  "ModuleName": "ejaTranslations",
  "Id": "existing_data_id_to_delete"
}

Note

Interactions with the server are performed using JSON POST requests.