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
- Python: Install Python 3.6 or higher.
- Modules: Use
pip install requests urllib3 configparserif needed. - Folder: Create a
JSONfolder (e.g.,C:\Users\YourName\Documents\JSON) for your files. - API Details: Get the API URL and a key from the Admin Panel (click the Eye Icon).
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
- API Key: Get it from the Admin Panel by clicking the Eye Icon.
- Security: Keep your key secret and regenerate it if compromised.
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 - Replace
API_KEY_HEREwith your key. - Replace
FILES_HEREwith your file path (e.g.,C:\Users\YourName\JSON\test.json). -i: Shows response headers;-k: Ignores SSL errors (use cautiously).
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- Add more
-F "files[]=@filename"for extra files.
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
- "Provide files or URL": Check file paths and ensure files exist.
- 400 Error: Verify API key and URL; use
curl -vfor details.
Programs Documentation
Program 1: 01_json_renamer.py
- What It Does: Renames JSON files to a pattern like
01_11_07_2025.json. - How to Use:
1. Save as
01_json_renamer.py. 2. Run:python .\01_json_renamer.py. 3. Select yourJSONfolder. - Output: Lists renamed files (e.g.,
01_11_07_2025.json).
Program 2: 02_json_checker.py
- What It Does: Checks JSON files and creates
upload_list.txtwith valid filenames. - How to Use:
1. Save as
02_json_checker.py. 2. Run:python .\02_json_checker.py. 3. Select yourJSONfolder. - Output: Shows [VALID] or [INVALID] files; creates
upload_list.txt.
Program 3: 03_json_uploader.py
- What It Does: Uploads valid files from
upload_list.txtto the API. - How to Use:
1. Save as
03_json_uploader.py. 2. Run:python .\03_json_uploader.py. 3. Enter API URL and key if first time. 4. Select yourJSONfolder. - Output: Shows upload status (e.g.,
01_11_07_2025.json : "success": True).
Workflow Example
- Put
test.jsoninJSONfolder. - Run
01_json_renamer.pyto rename it. - Run
02_json_checker.pyto validate and createupload_list.txt. - Run
03_json_uploader.pywith API details to upload.
Notes
Tip: Backup files before renaming or uploading. Check terminal messages for errors.