> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apinizer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Task-to-Task JSON Data Transfer and Usage

> You can transfer JSON data between API Integrator tasks. You can read data from an API that returns JSON data and send each element in the array-type elements in the returned result to another API in a loop.

**Scenario:** An API that returns JSON data will be called, and each of the array-type elements in the returned result will be sent to another API in a specific format.

In this case, two API Call connectors should be added as tasks. The first is for reading and the other is for writing in a loop.

## Task-1: Reading data with API Call connector

<Steps>
  <Step title="Add API Call task">
    Click the API Call option from the dialog listing tasks.
  </Step>

  <Step title="Select Once mode">
    Select the "Once" option to indicate that the task will run once.
  </Step>

  <Step title="Enter API access information">
    Enter the relevant API access information where data reading will be performed.
  </Step>

  <Step title="Set output key information">
    To use the data returned from the API in the next task, set the output key information to **"jsonResponse"**. (You can name this value as you wish.)
  </Step>
</Steps>

<img src="https://mintcdn.com/apinizer/VwbHLJfjvpJ4xBOY/images/tutorials/api-entagratoru/json.png?fit=max&auto=format&n=VwbHLJfjvpJ4xBOY&q=85&s=476c615ce5781f9afa9bc4081edac203" alt="Task-1: Reading data with API Call connector" width="1000" style={{ borderRadius: '0.5rem' }} data-path="images/tutorials/api-entagratoru/json.png" />

When this task runs, the following JSON Data is returned in this example, meaning the **jsonResponse** value will contain the following data:

```json theme={null}
{
 "users": [
  {
   "id": 1,
   "name": "user 1",
   "description": "Description of user 1"
  },
  {
   "id": 2,
   "name": "user 2",
   "description": "Description of user 2"
  },
  {
   "id": 3,
   "name": "user 3",
   "description": "Description of user 3"
  }
 ]
}
```

## Task-2: Sending data to API with API Call connector

<Steps>
  <Step title="Add API Call task">
    Click the API Call option from the dialog listing tasks.
  </Step>

  <Step title="Select Loop mode">
    Select the "Loop" option to indicate that work will be done in a loop on the array data from the previous task.
  </Step>

  <Step title="Specify JSONPath">
    Write as JSONPath which part of the output key information value entered in the previous task (**"jsonResponse"**) should be processed as an array.

    When writing JSON Path, add the **"#."** sign to the key information **("jsonResponse")** to indicate that JSON operations will be performed on the previous data. Then enter the path where the array elements are located as JSON Path. To indicate that all elements of the array will be processed, add the expression "\[\*]". In this case, for this example, the following should be written in the JSON Path field:

    ```
    {{jsonResponse#.users[*]}}
    ```
  </Step>

  <Step title="Enter target API access information">
    Enter the relevant API access information where the data will be sent.
  </Step>

  <Step title="Enter template message information">
    Enter the template message information you want to send. If you want to use the values of elements in the loop within the template message information, add the relevant data within the element to the template using the **"LOOP\_VARIABLE"** expression. Along with LOOP\_VARIABLE, the JSON Path information to access the JSON data within the element indicated as the target for the loop must be entered.
  </Step>
</Steps>

<img src="https://mintcdn.com/apinizer/VwbHLJfjvpJ4xBOY/images/tutorials/api-entagratoru/json2.png?fit=max&auto=format&n=VwbHLJfjvpJ4xBOY&q=85&s=e20fdb88cfb9e87b5eea567dc4902554" alt="Task-2: Sending data to API with API Call connector" width="1000" style={{ borderRadius: '0.5rem' }} data-path="images/tutorials/api-entagratoru/json2.png" />

In this example, when the expression `{{jsonResponse#.users[*]}}` is executed on the **jsonResponse** data returned from the previous task, 3 elements are returned, indicating that this task will run 3 times.

In the first run, the LOOP\_VARIABLE value will contain the following JSON.

```json theme={null}
{
 "id": 1,
 "name": "user 1",
 "description": "Description of user 1"
}
```

Let's assume the template to be executed on this JSON is as follows:

```json theme={null}
{
 "test_id":"{{LOOP_VARIABLE#.id}}",
 "test_name":"{{LOOP_VARIABLE#.name}}",
 "test_description":"{{LOOP_VARIABLE#.description}}"
}
```

In this case, the request body to be sent with API Call will be as follows:

```json theme={null}
{
 "test_id": "1",
 "test_name": "user 1",
 "test_description": "Description of user 1"
}
```
