Assets are binary files — photos, signatures, PDFs, or any other file — stored inside DB2 on the AS/400. Because DB2 column values have a character limit, the API automatically splits large files into small chunks and reassembles them on read. This is invisible to callers; you always work with whole files.
Every uploaded file is assigned a unique 16-character asset ID. This ID is what you store in your DB2 record (for example, on a stop or OSD entry) and pass back to retrieve the file later.
When you upload multiple files in a single request, you get back one ID per file. The id field
in the response is always the first file's ID and is the primary reference you should store. Use
ids when you need to track all files from a batch upload individually.
Uploads one or more files and stores them in DB2. Returns an asset ID for each file uploaded.
Endpoint: POST /api/assets
Authentication: None
Content-Type: multipart/form-data
| Field | Type | Required | Description |
|---|---|---|---|
files |
File (one or more) | Yes | The file(s) to upload. Send multiple files fields to upload a batch. |
mimetypes |
JSON object | No |
Override the MIME type for a specific file by filename. Example:
{"photo.bin": "image/jpeg"}. Useful when the detected MIME type is incorrect.
|
{
"success": true,
"message": "File(s) uploaded successfully.",
"data": {
"id": "0ks4j00000000000",
"ids": ["0ks4j00000000000", "0ks4j00000002a1f"]
}
}
id — Asset ID of the first uploaded file. This is what you store on your record.ids — Array of asset IDs, one per file, in the order they were uploaded.Result:
...
Downloads a single asset as a raw binary file. The server sets the correct
Content-Type (e.g. image/jpeg) and triggers a file download.
This is the endpoint to use when you want to open or display a file directly.
Endpoint: GET /api/assets/raw/:asset_id
Authentication: None
| Parameter | Description |
|---|---|
asset_id |
The 16-character asset ID returned when the file was uploaded. |
Raw binary file bytes with the appropriate Content-Type header. Not a JSON response.
Returns the asset(s) as an array of base64-encoded
data URLs
(e.g. data:image/jpeg;base64,/9j/4AAQ...).
Each element in the array is a complete, self-contained file that can be embedded directly in HTML or decoded to bytes.
If the original upload was a batch of multiple files, the array contains one entry per file.
Endpoint: GET /api/assets/:asset_id
Authentication: None
| Parameter | Description |
|---|---|
asset_id |
The 16-character asset ID returned when the file was uploaded. |
{
"success": true,
"message": "Asset(s) retrieved successfully.",
"data": [
"data:image/jpeg;charset=utf-8;base64,/9j/4AAQSkZJRgAB...",
"data:image/png;charset=utf-8;base64,iVBORw0KGgoAAAA..."
]
}
Result:
...
When multiple files are uploaded together, only the first file's ID is stored as the primary reference. This endpoint accepts that primary ID and returns the individual asset ID for every file in the batch — one ID per file, in upload order. Use those IDs to download each file separately via the raw or data URL endpoints.
Endpoint: GET /api/assets/ids/:asset_id
Authentication: None
| Parameter | Description |
|---|---|
asset_id |
The 16-character asset ID (typically the primary id from the upload response). |
{
"success": true,
"message": "Asset IDs retrieved successfully.",
"data": [
"0ks4j00000000000",
"0ks4j00000002a1f"
]
}
Result:
...
The most common use case from an AS/400 program is downloading an asset (e.g. a delivery photo or signature)
that was captured by the POD app. The example below fetches an asset as a raw file using the
GET /api/assets/raw/:asset_id endpoint and saves it to the IFS.
The asset ID (16-character string) would typically be stored in a DB2 field on the stop or OSD record —
for example, PDSIGID for a signature or a custom field you've added for a photo.
/* ------------------------------------------------------------------ */
/* Download a POD asset (photo / signature) from the API */
/* and save the raw file bytes to the IFS. */
/* ------------------------------------------------------------------ */
Define_Com Class(#PRIM_HTTP) Name(#Http)
Define_Com Class(#PRIM_ALPH) Name(#AssetId) With_Value('0ks4j00000000000')
Define_Com Class(#PRIM_ALPH) Name(#BaseUrl) With_Value('https://pod.gscserver.com/api/assets/raw/')
Define_Com Class(#PRIM_ALPH) Name(#Url)
Define_Com Class(#PRIM_ALPH) Name(#SavePath) With_Value('/tmp/pod_asset.jpg')
Define_Com Class(#PRIM_BYTS) Name(#FileBytes)
Define_Com Class(#PRIM_BOLN) Name(#Ok)
/* Build the full URL */
#Url := #BaseUrl + #AssetId
/* Make the GET request */
#Http.GetUrl( #Url )
#Ok := (#Http.ResponseStatus = 200)
If (#Ok)
/* ResponseBody contains the raw file bytes */
#FileBytes := #Http.ResponseBytes
/* Write bytes to IFS — adapt path and filename as needed */
/* Use your preferred IFS write method here */
Message Text('Asset downloaded successfully.')
Else
Message Text('Failed to download asset. HTTP status: ' + #Http.ResponseStatus.AsString)
Endif
If a stop has multiple photos attached (uploaded as a batch), you first call /api/assets/ids/:asset_id
to get the individual ID for each photo, then loop and download each.
/* ------------------------------------------------------------------ */
/* Get individual asset IDs from a batch, then download each file. */
/* Assumes #AssetId holds the primary asset ID from the stop record. */
/* ------------------------------------------------------------------ */
Define_Com Class(#PRIM_HTTP) Name(#Http)
Define_Com Class(#PRIM_JSON) Name(#Json)
Define_Com Class(#PRIM_JSONR) Name(#JsonRoot)
Define_Com Class(#PRIM_JSONR) Name(#DataArray)
Define_Com Class(#PRIM_JSONR) Name(#IdEntry)
Define_Com Class(#PRIM_ALPH) Name(#AssetId) With_Value('0ks4j00000000000')
Define_Com Class(#PRIM_ALPH) Name(#FileId)
Define_Com Class(#PRIM_ALPH) Name(#Url)
Define_Com Class(#PRIM_ALPH) Name(#SavePath)
Define_Com Class(#PRIM_INT4) Name(#Index)
/* Step 1 – get the list of individual file IDs */
#Url := 'https://pod.gscserver.com/api/assets/ids/' + #AssetId
#Http.GetUrl( #Url )
If (#Http.ResponseStatus = 200)
#Json.Parse( #Http.ResponseBody )
#JsonRoot := #Json.RootObject
#DataArray := #JsonRoot.GetObject( 'data' )
/* Step 2 – loop over each ID and download the file */
#Index := 1
For Each (#IdEntry) In (#DataArray.Items)
#FileId := #IdEntry.AsAlpha
/* Build save path — e.g. /tmp/pod_photo_1.jpg */
#SavePath := '/tmp/pod_photo_' + #Index.AsString + '.jpg'
/* Download raw file */
#Url := 'https://pod.gscserver.com/api/assets/raw/' + #FileId
#Http.GetUrl( #Url )
If (#Http.ResponseStatus = 200)
/* Write #Http.ResponseBytes to IFS at #SavePath */
Message Text('Downloaded file ' + #Index.AsString + ': ' + #FileId)
Endif
#Index += 1
Endfor
Endif
Note: Class names like #PRIM_HTTP, #PRIM_JSON, and #PRIM_JSONR
are standard Visual LANSA primitives. Adapt IFS write logic to your preferred method
(#PRIM_FILS or a service program call). Use https://pod.gscserver.com
for production and https://pod.dev.gscserver.com for dev/test.