JSON Upload System Report

Introduction

This report combines documentation for the API and the Python programs used to manage and upload JSON files. It's designed to be simple and easy to follow, especially for new developers. The system helps you rename, check, and upload JSON files to the API at

https://api.bhslogistics.dk/api/upload

Prerequisites

API Documentation

Overview

The API lets you upload JSON files to https://api.bhslogistics.dk/api/upload using curl. It needs an API key for security and returns detailed responses.

Authentication

Upload Commands

Single File Upload

curl -X POST -H "apikey: API_KEY_HERE" -F "files[]=@FILES_HERE" https://api.bhslogistics.dk/api/upload -i -k
Example:

curl -X POST -H "apikey: 8d7cb7aa352ed594c97ab31ffbb9f316775a2504" -F "files[]=@test.json" https://api.bhslogistics.dk/api/upload -i -k

Multiple File Upload

curl -X POST -H "apikey: API_KEY_HERE" -F "files[]=@FILES_HERE" -F "files[]=@FILES_HERE" https://api.bhslogistics.dk/api/upload -i -k
Example:

curl -X POST -H "apikey: 8d7cb7aa352ed594c97ab31ffbb9f316775a2504" -F "files[]=@test.json" -F "files[]=@test2.json" https://api.bhslogistics.dk/api/upload -i -k

API Response

Success (Single File)

HTTP/1.1 200 OK { "results": [{"category": "success", "file_path": "/Upload_test/BHSuat/2025_06_06/080406_test.json", "filename": "test.json", "ftp_host": "10.6.8.43", "message": "Uploaded: 080406_test.json", "success": true}], "success": true }

Success (Multiple Files)

HTTP/1.1 200 OK
{
  "results": [
    {"category": "success", "file_path": "/Upload_test/BHSuat/2025_06_06/080513_test.json", "filename": "test.json", "ftp_host": "10.6.8.43", "message": "Uploaded: 080513_test.json", "success": true},
    {"category": "success", "file_path": "/Upload_test/BHSuat/2025_06_06/080513_test.json", "filename": "test.json", "ftp_host": "10.6.8.43", "message": "Uploaded: 080513_test.json", "success": true}
  ],
  "success": true
}

Error

HTTP/1.1 400 Bad Request
{
  "category": "error",
  "message": "Provide files or URL",
  "success": false
}

Troubleshooting

Programs Documentation

Program 1: 01_json_renamer.py

Program 2: 02_json_checker.py

Program 3: 03_json_uploader.py

Workflow Example

  1. Put test.json in JSON folder.
  2. Run 01_json_renamer.py to rename it.
  3. Run 02_json_checker.py to validate and create upload_list.txt.
  4. Run 03_json_uploader.py with API details to upload.

Notes

Tip: Backup files before renaming or uploading. Check terminal messages for errors.