Groovy Script
Explanation
This script performs the following operations:- Parsing JSON: Parses the incoming JSON request body using
JsonSlurper. - Creating Form Data: Creates an entity in multipart/form-data format using
MultipartEntityBuilder. - Dynamic Field Addition: Adds each key-value pair in JSON to form data.
- Sending HTTP Request: Sends HTTP POST request with the created form data.
- Response Processing: Receives the result of the request and assigns it to necessary variables.
Usage Scenario
This script is used to convert a request in JSON format to form data format and send it to the backend service. It is particularly useful when the backend service expects data in form data format.This script should be run on the request line (Request Policy) because it uses the
requestBodyTextToTargetAPI variable.
