ScriptlessAutomation
  • 👋Welcome to Scriptless Automation
  • Discover More About Automation
    • ⚙️Automation platform intro
    • 💡Advantages of Scriptless Automation
    • 🚀Release Notes
      • 📖Open Code
      • 📕License Code
  • Product tools
    • 📪Pre-request Tools
    • 🔧Project Dependencies
  • Automation Architecture
    • 🎨Flow diagram
  • Get Started
    • 🛠️Start with Automation
    • 📖Open Code Automation
      • 🌏Web Automation
      • ↔️API Automation
    • 🏢Maven Configuration
    • 🗜️Setting Up Maven Project in IntelliJ IDEA
    • 🎛️Scriptless Config
      • 🕸️BrowserConfiguration
        • chrome.properties
      • 👥CommunicationConfiguration
        • SlackConfiguration.properties
      • 📧MailConfiguration
        • gmailCredentials.properties
      • 🛂ReportConfiguration
        • extentReportConfiguration.properties
      • 🕵️TestManagementConfiguration
        • testRail.properties
        • zephyrscale.properties
        • testiny.properties
      • ⚙️testNgConfiguration.properties
    • 🍱TestData Configuration
    • 👨‍💼Gherkin Language and Scriptless Automation Framework
  • Automation Import Notes
    • 🎨Points to Remember
  • Automation Platforms
    • 👾ScriptlessApi Automation
      • 🖊️Introduction
      • 🗜️Api Automation Setup
      • 🔃Supported API Request Types
      • 🪧API Automation Template
      • 📚Example of API Requests
        • ⬇️GET
        • ↕️POST
        • ⤵️PUT
        • ❌DELETE
      • 🎯API Response Validation
      • 👨‍👦API Dependent TestCase
      • 📝Store API Variables
      • 📔API with JSON body
      • 🙋‍♂️Api Wait
      • 🗜️API Schema Validation
      • 🏗️API Tailor-Made coding
      • 👨‍🦯API Support Generator
      • ↘️Api Response Store Objects
      • ✍️API Test Report
      • 🚃Api Response Type Validation
    • 🌐ScriptlessWeb Automation
      • 🖊️Introduction
      • 🗜️Web Automation Setup
      • 🪧Web Automation Template
      • 🧮page_object_locators
      • 📜Web Automation Key Phrases
        • 📃PAGE_NAME
        • ⌛WAIT_TYPE
        • 📜SCROLL_TYPE
        • 👨‍💼ELEMENT_NAME
        • 🏎️ACTIONS
        • ⌨️SEND_KEYS
        • ✔️VALIDATION
        • ✅VALIDATION_TYPE
      • 👨‍👦Web Dependent Test Case
      • 🐒MOCK
      • 🛂AutomationAsserts
      • 🏗️Web Tailor-Made coding
      • 📝Store Web Variables
      • 🤼‍♀️Web & API integration
      • 🖇️Dynamic Strings
      • 🗣️ReadFile Annotation for Custom Code
      • 🖼️Page_Comparison
      • 👨‍💼Gherkin Template for Web Automation
    • 📱Mobile Automation
  • 🪶Automation features
    • 🌲Environment and System Variables
    • 🗝️KeyInitializers
      • Types of KeyInitializers
    • ✍️Reporting
      • Dashboard
      • Category
      • Tests
        • Screenshot Section
    • 👯Parallel Testing
    • 🏗️Tailor-Made Coding
  • ⏩Automation Demo
Powered by GitBook
On this page
  • Introduction
  • Using the JSON Body Feature
  • Advantages of JSON Body Feature
  • Conclusion

Was this helpful?

  1. Automation Platforms
  2. ScriptlessApi Automation

API with JSON body

Introduction

The JSON Body feature in scriptless automation provides a simplified way to handle complex JSON structures by referencing external JSON files or using dynamic JSON values. This functionality allows for cleaner CSV files and more manageable automation scripts.

Using the JSON Body Feature

There are two primary ways to utilize the JSON Body feature:

1. Direct Use of JSON File

Users can create a JSON file and store it in the specified directory, then reference it within their CSV template. This method is ideal for static JSON payloads that do not change frequently.

File Directory

 ProjectDirectory/test_data/api/JsonRepository
 
[ProjectDirectory]
│ 
├───[testdata]
│    └───[API]
│         └───[JsonRepository]
│              └───[JsonFileName.json]
│         └───[test_case_flows]
│              └───[TestDirectory]
│                   └───[TestID_GroupName.csv]

Syntax for CSV Template

BODY:KEY,JsonRepository
BODY:VALUE,JsonFileName

Example

DEPENDANT_TEST_CASE,NONE,
END_POINT,https://api-generator.retool.com/7kbSLy/data,
METHOD,POST,
PARAMS:KEY,NONE,
PARAMS:VALUE,NONE,
AUTH:KEY,NONE,
AUTH:VALUE,NONE,
HEADERS:KEY,Content-Type,
HEADERS:VALUE,application/json,
BODY:KEY,JsonRepository,
BODY:VALUE,test,
RESPONSE:CODE,201,
RESPONSE:JSON_PATH,NONE,'Column 1',id
RESPONSE:EXPECTED_VALUE,NONE,PrecisionTestAutomation,NONE
RESPONSE:STORE_VALUE,NONE,Name,ID

JSON File

{"Column 1":"PrecisionTestAutomation"}

2. Using Dynamic JSON Value

For scenarios requiring dynamic JSON values, users can define a JSON schema and specify placeholders that can be replaced with actual values in the CSV file.

JSON Schema Example

{
    "Column 1":"{{name}}"
}

CSV Template with Dynamic JSON Value

DEPENDANT_TEST_CASE,NONE,
END_POINT,https://api-generator.retool.com/7kbSLy/data,
METHOD,POST,
PARAMS:KEY,NONE,
PARAMS:VALUE,NONE,
AUTH:KEY,NONE,
AUTH:VALUE,NONE,
HEADERS:KEY,Content-Type,
HEADERS:VALUE,application/json,
BODY:KEY,JsonRepository,name  // 'name' is the dynamic field in the JSON
BODY:VALUE,test,PrecisionTestAutomation  // 'test' is the JSON file, 'PrecisionTestAutomation' is the value for 'name'
RESPONSE:CODE,201,
RESPONSE:JSON_PATH,NONE,'Column 1',id
RESPONSE:EXPECTED_VALUE,NONE,PrecisionTestAutomation,NONE
RESPONSE:STORE_VALUE,NONE,Name,ID

In this approach, the placeholder {{name}} in the JSON file will be replaced with the value PrecisionTestAutomation specified in the BODY:VALUE field.

Advantages of JSON Body Feature

  • Maintainability: Separating the JSON body from the CSV file reduces clutter and makes the automation scripts easier to maintain.

  • Scalability: Managing JSON structures becomes more scalable as changes to the JSON do not require modifications to the CSV template.

  • Flexibility: Supports both static and dynamic JSON payloads, allowing for a wide range of testing scenarios.

Conclusion

The JSON Body feature enhances scriptless automation by offering an efficient way to manage JSON payloads. By enabling the direct use of JSON files or dynamic JSON values, it allows for a more organized approach to API testing with complex JSON structures. This feature streamlines the process of configuring API requests, especially for those that require large or frequently changing JSON bodies.

PreviousStore API VariablesNextApi Wait

Last updated 1 year ago

Was this helpful?

👾
📔