Schedule MacroRIS-SM-2036 – JSON TO CSV

JSON to CSV FTP Integration

Retrieve product stock data from an external JSON API, convert it into CSV format, and upload it to an FTP server for integration with external systems.

Overview

The JSON to CSV FTP Integration macro fetches product stock data from an external API, converts it into a CSV file, and uploads it to an FTP server.

It acts as a bridge between modern API-based data sources and systems that require flat file formats like CSV.

Ensure API endpoint and FTP credentials are correctly configured before executing this macro.

Purpose

This macro:

  • Fetches product stock data from API
  • Converts JSON response into CSV format
  • Uploads file to FTP server
  • Enables system integration using CSV

👉 In short:
Convert API data into CSV and upload to FTP.

When It Runs

Used for stock synchronization and integrations

Typically runs:

  • Scheduled execution (recommended)
  • Manual execution
  • During supplier stock update workflows

Parameters

path
apiEndpointstring
Required

API endpoint used to fetch product stock data.

path
ftpServerstring
Required

FTP server URL where the file will be uploaded.

path
ftpUserNamestring
Required

FTP username for authentication.

path
ftpPasswordstring
Required

FTP password for authentication.

path
ftpSSLboolean
Required

Enable or disable SSL for FTP connection.

path
ftpFilePathstring
Required

Destination folder path on FTP server.

How It Works

Start Execution

Initialize macro and log execution start.

Fetch API Data

Call external API and retrieve JSON response using HTTP client.

Parse JSON Data

Deserialize JSON response into product objects.

Convert to CSV

Transform product data into CSV format including:

  • SKU (productId)
  • Stock (100 or 0)
  • Stock Status (Yes/No)

Prepare File

Generate file name: Update.csv

Upload to FTP

Upload CSV file to configured FTP location using FTP proxy.

Log Execution

Record API response status and FTP upload result.

Final Result

  • Product data fetched from API
  • Data converted into CSV format
  • File uploaded to FTP server
  • Ready for external system consumption

Usefulness

This macro is highly beneficial for:

  • Automating supplier stock updates
  • Converting API data into simple formats
  • Supporting legacy system integrations
  • Reducing manual effort
  • Ensuring consistent stock synchronization

Important Notes

  • Depends on API availability and response structure
  • FTP credentials must be configured correctly
  • No retry mechanism for API or FTP failures
  • Uses fixed stock logic (100 or 0 only)
  • No validation for incorrect JSON data
  • File overwrites existing file if same name is used

Example Scenario

Key Insight

By transforming dynamic API responses into a standardized CSV format, this macro enables seamless integration between modern APIs and legacy systems that rely on file-based data exchange.