JSON to XML API¶
Overview¶
Convert JSON input to XML. Body mode runs synchronously. URL and file modes submit an asynchronous job.
Endpoint¶
POST https://api.apidatatools.com/json-to-xml-api
Authentication¶
Include your API key in the x-api-key header.
Input modes¶
| Mode | Description | Response |
|---|---|---|
body | Send JSON text in the request body. This is the default mode. | Synchronous |
url | Submit a URL to a JSON file. | Asynchronous |
file | Submit a pre-uploaded file’s storage key. | Asynchronous |
Headers¶
Header names are case-insensitive. The lowercase spellings below are used in examples.
| Header | Type | Required | Default / values | Description |
|---|---|---|---|---|
x-api-key | String | Yes | None | Your API key. |
x-source-type | String | No | body; accepted values: body, url, file | Selects the input mode. |
Accepted file extensions¶
URL and file modes accept these extensions:
.txt.json.log
Request body¶
Body mode¶
Send the JSON input as raw text in the request body, not as a JSON wrapper object.
{"name":"Ada","active":true}
URL mode¶
Send a JSON object with a url property:
{"url":"https://example.com/input.json"}
File mode¶
Send a JSON object with a file property. Its value must be the exact storage key returned by the upload workflow.
{"file":"S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"}
curl examples¶
Body mode¶
x-source-type is omitted here to use its default, body.
curl --request POST \
--url https://api.apidatatools.com/json-to-xml-api \
--header 'x-api-key: YOUR_API_KEY' \
--data-raw '{"name":"Ada","active":true}'
URL mode¶
curl --request POST \
--url https://api.apidatatools.com/json-to-xml-api \
--header 'x-api-key: YOUR_API_KEY' \
--header 'x-source-type: url' \
--data-raw '{"url":"https://example.com/input.json"}'
File mode¶
curl --request POST \
--url https://api.apidatatools.com/json-to-xml-api \
--header 'x-api-key: YOUR_API_KEY' \
--header 'x-source-type: file' \
--data-raw '{"file":"S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"}'
Success responses¶
Synchronous body mode¶
A successful conversion returns HTTP 200. The response includes the request ID, success status, a temporary output-file URL, and a preview.
{
"request_id": "REQUEST_ID",
"status": "success",
"file": "https://downloads.apidatatools.com/OUTPUT_FILE",
"preview": "XML_OUTPUT_PREVIEW"
}
Asynchronous URL and file modes¶
A successfully submitted job returns HTTP 202.
{
"status": "accepted",
"job_id": "JOB_ID",
"status_url": "https://api.apidatatools.com/jobs/JOB_ID",
"request_id": "REQUEST_ID"
}
Async job status¶
Retrieve a submitted job’s status with:
GET https://api.apidatatools.com/jobs/{job_id}
Include x-api-key with the request. The status response includes request_id, job_id, status, created_at, and updated_at.
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": 1700000000,
"updated_at": 1700000000,
"message": "Your job is being processed.",
"retry_after": 2
}
A processing response has the same fields, with "status": "processing".
For a successful job, the response includes a result object:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "success",
"created_at": 1700000000,
"updated_at": 1700000001,
"result": {
"status": "success",
"file": "https://downloads.apidatatools.com/OUTPUT_FILE",
"preview": "XML_OUTPUT_PREVIEW"
}
}
For a failed job, the response includes an error object:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "failed",
"created_at": 1700000000,
"updated_at": 1700000001,
"error": {
"code": "ERROR_CODE",
"message": "Error message",
"details": {}
}
}
Error handling¶
Errors use this response envelope. details can contain additional fields; details.message is included.
{
"status": "error",
"error": "ERROR_CODE",
"request_id": "REQUEST_ID",
"details": {
"message": "Error message"
}
}
Synchronous request errors¶
| HTTP status | Error codes |
|---|---|
400 | INVALID_SOURCE_TYPE, INVALID_BODY_ENCODING, EMPTY_BODY; conversion validation errors |
401 | UNAUTHORIZED |
404 | USER_NOT_FOUND, UNKNOWN_FUNCTION |
413 | PAYLOAD_TOO_LARGE |
429 | QUOTA_EXCEEDED, RATE_LIMITED |
500 | PLAN_NOT_FOUND, INTERNAL_ERROR |
Conversion validation errors are returned with HTTP 400; their specific codes depend on the error.
Async submission errors¶
| HTTP status | Error codes |
|---|---|
400 | INVALID_BODY, INVALID_URL, URL_UNREACHABLE, URL_NOT_OK, INVALID_FILE, FILE_UNAVAILABLE, INVALID_FILE_EXTENSION |
413 | FILE_TOO_LARGE |
500 | CONFIG_ERROR, PLAN_CONFIG_ERROR |
Errors that occur while processing a job, such as DOWNLOAD_FAILED or UPLOAD_FAILED, are reported in the job’s failed status response; they are not HTTP statuses for the initial job submission.
Job status request errors¶
The job status endpoint returns these tool errors with HTTP 400: INVALID_JOB_ID, DDB_ERROR, JOB_NOT_FOUND, and FORBIDDEN. An unexpected server error is returned with HTTP 500 and code INTERNAL_ERROR.
Notes¶
- Body-size, file-size, quota, and rate limits depend on your plan. See tool limits.
- Output download URLs are temporary. Retention depends on your plan.