XML to Base64 API¶
Overview¶
Convert XML input to Base64 using the XML-to-Base64 endpoint. Body mode processes the submitted text synchronously. URL and file modes submit an asynchronous job.
Endpoint¶
Method: POST
URL: https://api.apidatatools.com/xml-to-base64-api
Authentication¶
Include your API key in the x-api-key header with every request:
x-api-key: YOUR_API_KEY
Input modes¶
Select the input mode with x-source-type:
| Mode | Processing | Input |
|---|---|---|
body | Synchronous | Raw text in the request body |
url | Asynchronous | JSON containing a URL |
file | Asynchronous | JSON containing a pre-uploaded file reference |
If x-source-type is omitted, the mode defaults to body.
Headers¶
| Header | Type | Required | Default / values | Description |
|---|---|---|---|---|
x-api-key | String | Yes | — | Your API key. |
x-source-type | String | No | Default: body. Values: body, url, file. | Chooses the input mode. |
Accepted file extensions¶
For URL and file modes, the accepted extensions are txt, xml, and log.
Request body¶
Body mode¶
Send the XML as raw text in the request body. This endpoint accepts a text body, not a binary body.
URL mode¶
Send a JSON object with a url property:
{"url":"https://example.com/input.xml"}
The URL must be a valid, reachable HTTP or HTTPS URL. The remote file must use an accepted extension.
File mode¶
Send a JSON object with a file property containing the exact storage key returned by the upload workflow:
{"file":"S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"}
The referenced file must be available and use an accepted extension.
cURL examples¶
Body mode¶
curl -X POST 'https://api.apidatatools.com/xml-to-base64-api' \
-H 'x-api-key: YOUR_API_KEY' \
--data '<root><item>example</item></root>'
URL mode¶
curl -X POST 'https://api.apidatatools.com/xml-to-base64-api' \
-H 'x-api-key: YOUR_API_KEY' \
-H 'x-source-type: url' \
--data '{"url":"https://example.com/input.xml"}'
File mode¶
curl -X POST 'https://api.apidatatools.com/xml-to-base64-api' \
-H 'x-api-key: YOUR_API_KEY' \
-H 'x-source-type: file' \
--data '{"file":"S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"}'
Success responses¶
Synchronous body mode¶
A successful synchronous response is HTTP 200. Depending on the response type, the JSON response contains one of these shapes.
For a file-producing result:
{
"request_id": "REQUEST_ID",
"status": "success",
"file": "TEMPORARY_DOWNLOAD_URL",
"preview": "..."
}
For a data-producing result:
{
"request_id": "REQUEST_ID",
"status": "success",
"preview": "..."
}
The data-producing preview is serialized JSON. Download URLs are temporary; retention depends on your plan.
URL and file modes¶
A successfully accepted asynchronous request returns HTTP 202:
{
"status": "accepted",
"job_id": "JOB_ID",
"status_url": "https://api.apidatatools.com/jobs/JOB_ID",
"request_id": "REQUEST_ID"
}
Acceptance means the job was submitted; check its status to determine the outcome.
Async job status¶
Retrieve a job’s status with:
curl -X GET 'https://api.apidatatools.com/jobs/JOB_ID' \
-H 'x-api-key: YOUR_API_KEY'
The status response includes request_id, job_id, status, created_at, and updated_at.
Queued and processing¶
For queued and processing jobs, the response also includes a message and retry interval:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "queued",
"created_at": 0,
"updated_at": 0,
"message": "Your job is being processed.",
"retry_after": 2
}
For a processing job, status is "processing"; the other fields have the same shape.
Success¶
A successful job includes a result object:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "success",
"created_at": 0,
"updated_at": 0,
"result": {
"status": "success",
"file": "TEMPORARY_DOWNLOAD_URL",
"preview": "..."
}
}
Failed¶
A failed job includes an error object:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "failed",
"created_at": 0,
"updated_at": 0,
"error": {
"code": "ERROR_CODE",
"message": "Error message",
"details": {
"message": "Error message"
}
}
}
The details object may contain additional error information.
Error handling¶
Synchronous and asynchronous request errors use this envelope:
{
"status": "error",
"error": "ERROR_CODE",
"request_id": "REQUEST_ID",
"details": {
"message": "Error message"
}
}
Additional fields may appear in details.
HTTP errors¶
| HTTP status | Error codes |
|---|---|
400 | INVALID_SOURCE_TYPE, INVALID_BODY_ENCODING, EMPTY_BODY; tool-specific conversion errors; and, for asynchronous input, INVALID_BODY, INVALID_URL, URL_UNREACHABLE, URL_NOT_OK, INVALID_FILE, FILE_UNAVAILABLE, INVALID_FILE_EXTENSION. |
401 | UNAUTHORIZED |
404 | USER_NOT_FOUND, UNKNOWN_FUNCTION |
413 | PAYLOAD_TOO_LARGE; FILE_TOO_LARGE for asynchronous input validation. |
429 | QUOTA_EXCEEDED, RATE_LIMITED |
500 | PLAN_NOT_FOUND, INTERNAL_ERROR; asynchronous configuration errors CONFIG_ERROR and PLAN_CONFIG_ERROR. |
Errors from the job-status endpoint, including INVALID_JOB_ID, JOB_NOT_FOUND, FORBIDDEN, and DDB_ERROR, are returned as HTTP 400 by that endpoint.
Asynchronous jobs can also fail with INVALID_JOB, FILE_TOO_LARGE, DOWNLOAD_FAILED, UPLOAD_FAILED, or INTERNAL_ERROR. These are reported in the job’s failed status; they are not the HTTP status of the original job-submission request.
Notes¶
- Body mode is synchronous; URL and file modes are asynchronous.
- Request-body and file-size limits, quota, rate limits, and download retention depend on your plan. See Tool limits.
- Download URLs are temporary, and their retention period depends on your plan.