Base64 to XML API Documentation¶
Overview¶
The Base64 to XML API converts a Base64-encoded XML string into a decoded, well-formed XML document.
It validates the decoded XML for correctness and returns the XML content as a downloadable file.
This API supports synchronous (direct body input) and asynchronous (remote URL or uploaded file) modes.
Endpoint (POST)¶
POST https://api.apidatatools.com/base64-to-xml-api
Headers¶
| Header | Type | Required | Description |
|---|---|---|---|
x-api-key | string | Yes | Your API key for authentication |
Content-Type | string | Yes | Must be application/json |
x-source-type | string | No | Defines input mode: body (default), url, or file |
Accepted File Extensions¶
| Mode | Allowed Extensions |
|---|---|
| URL / File | txt, log |
Input Example (Body Mode)¶
PG5vdGU+SGVsbG8gV29ybGQ8L25vdGU+
The value is a Base64-encoded XML string.
Example above decodes to <note>Hello World</note>.
Input Example (URL Mode)¶
{
"url": "https://example.com/sample_base64.txt"
}
The remote file must contain a Base64-encoded XML string.
This mode triggers asynchronous processing.
Input Example (File Mode)¶
{
"file": "user_uploads/upl_1234567890abcdef/sample_base64.log"
}
The file must be previously uploaded using the upload API.
This mode triggers asynchronous processing.
Example Request¶
Synchronous (Body Input)¶
curl -X POST "https://api.apidatatools.com/base64-to-xml-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "x-source-type: body" \
-d 'PG5vdGU+SGVsbG8gV29ybGQ8L25vdGU+'
Asynchronous (Remote File URL)¶
curl -X POST "https://api.apidatatools.com/base64-to-xml-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "x-source-type: url" \
-d '{"url": "https://example.com/sample_base64.txt"}'
Asynchronous (Input File)¶
curl -X POST "https://api.apidatatools.com/base64-to-xml-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "x-source-type: file" \
-d '{"file": "user_uploads/upl_1234567890abcdef/sample_base64.log"}'
Example Response¶
Successful (Body Mode)¶
{
"status": "success",
"request_id": "b1a2c3d4-e5f6-7890-abcd-ef1234567890",
"file": "https://downloads.apidatatools.com/apidatatools_convert_abcdef1234567890.xml",
"preview": "<note>Hello World</note>"
}
Async Job Accepted¶
{
"status": "accepted",
"job_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"status_url": "https://api.apidatatools.com/jobs/a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"request_id": "b1a2c3d4-e5f6-7890-abcd-ef1234567890"
}
Error Handling¶
| Error Code | HTTP Status | Description | Example |
|---|---|---|---|
INVALID_BASE64 | 400 | Input could not be Base64-decoded | {"status":"error","error":"INVALID_BASE64","details":{"message":"Base64 decoding failed."}} |
INVALID_UTF8 | 400 | Decoded content is not valid UTF-8 | {"status":"error","error":"INVALID_UTF8","details":{"message":"Decoded Base64 is not valid UTF-8 XML."}} |
INVALID_XML | 400 | Decoded XML is not well-formed | {"status":"error","error":"INVALID_XML","details":{"message":"Decoded XML is not well-formed."}} |
INVALID_URL | 400 | URL missing or invalid | {"status":"error","error":"INVALID_URL","details":{"message":"Missing or invalid 'url'."}} |
URL_UNREACHABLE | 400 | Remote URL could not be reached | {"status":"error","error":"URL_UNREACHABLE","details":{"message":"Could not reach URL"}} |
URL_NOT_OK | 400 | Remote URL returned non-200 status | {"status":"error","error":"URL_NOT_OK","details":{"message":"URL returned HTTP 404, expected 200."}} |
FILE_TOO_LARGE | 413 | File exceeds plan limit | {"status":"error","error":"FILE_TOO_LARGE","details":{"message":"Remote file exceeds plan limit."}} |
INVALID_FILE_EXTENSION | 400 | File extension not allowed | {"status":"error","error":"INVALID_FILE_EXTENSION","details":{"message":"Invalid or unsupported file extension"}} |
EMPTY_BODY | 400 | Request body is empty | {"status":"error","error":"EMPTY_BODY","details":{"message":"Request body is empty."}} |
PAYLOAD_TOO_LARGE | 413 | Body exceeds plan limit | {"status":"error","error":"PAYLOAD_TOO_LARGE","details":{"message":"Request body exceeds limit"}} |
INTERNAL_ERROR | 500 | Unexpected internal failure | {"status":"error","error":"INTERNAL_ERROR","details":{"message":"Failed to process your request"}} |
Async Job Status¶
To check the status of an asynchronous job, use the status_url returned in the accepted response.
Endpoint¶
GET https://api.apidatatools.com/jobs/{job_id}
Example Status Response for Async¶
Queued / Processing¶
{
"job_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"status": "queued",
"created_at": 1712345678,
"updated_at": 1712345678,
"message": "Your job is being processed.",
"retry_after": 2
}
Successful Completion¶
{
"job_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"status": "success",
"created_at": 1712345678,
"updated_at": 1712345690,
"result": {
"status": "success",
"request_id": "b1a2c3d4-e5f6-7890-abcd-ef1234567890",
"file": "https://downloads.apidatatools.com/apidatatools_convert_abcdef1234567890.xml",
"preview": "<note>Hello World</note>"
}
}
Failed Job¶
{
"job_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"status": "failed",
"created_at": 1712345678,
"updated_at": 1712345680,
"error": {
"code": "INVALID_XML",
"message": "Decoded XML is not well-formed.",
"details": {
"line": 3,
"column": 15
}
}
}
Notes for Developers¶
-
The API supports three modes:
-
Body Mode: Direct Base64 string in request body (synchronous).
- URL Mode: Remote file URL containing Base64 XML (asynchronous).
- File Mode: Uploaded file reference (asynchronous).
- Each response includes a unique
request_idfor traceability. - Asynchronous jobs can be monitored using the
status_urlprovided in the accepted response. - Output files are stored temporarily and accessible via a secure download link.
- Allowed file extensions for URL/File mode:
.txt,.log. - The preview field in responses contains the first 100 KB of the decoded XML for quick inspection.