Errors
Unsupported File Type
415 - The file type is not supported for this operation
Overview
The 415 Unsupported File Type error occurs when you attempt to perform an operation on a file that doesn't support the requested file format.
HTTP Status Code
415
Error Response
{
"type": "https://scan-documents.com/docs/errors/unsupported-file-type",
"title": "Unsupported File Type",
"status": 415,
"message": "The file type is not supported."
}Common Causes
- Uploading a file with an unsupported file extension
- Attempting to perform an operation that doesn't support the file's format
- File MIME type doesn't match the actual file content
- Corrupted file that can't be properly identified
- Using the wrong endpoint for a specific file type
Supported File Types
Image Files
- Supported formats: PNG, JPEG, JPG, WebP, TIFF
- Max file size: 10MB per image
- Use cases: Scanning, OCR, conversion, warping, effect application
PDF Files
- Supported formats: PDF
- Max file size: 50MB per PDF
- Use cases: Splitting, merging, extracting pages, rendering
Document Files
For document processing operations:
- Images: PNG, JPEG, JPG, WebP
- PDFs: PDF
How to Fix
- Verify File Type: Check that your file is in a supported format:
# On Linux/Mac, check file type
file document.pdf
# Expected output for PDF
# document.pdf: PDF document, version 1.4- Convert Unsupported Files: If your file is in an unsupported format, convert it first:
// Example: Convert HEIC to JPEG before uploading
const convertedImage = await convertHEICtoJPEG(originalFile);
// Then upload the converted file
const formData = new FormData();
formData.append('file', convertedImage);
const response = await fetch('https://api.scan-documents.com/v1/files', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
},
body: formData
});- Check Operation Compatibility: Ensure you're using the correct endpoint for your file type:
// PDF operations - only for PDF files
POST /v1/pdf-operations/split
POST /v1/pdf-operations/merge
// Image operations - for image files
POST /v1/image-operations/scan-image
POST /v1/image-operations/convert- Validate MIME Type: Ensure the file's MIME type matches its actual format:
const formData = new FormData();
const file = new File([blob], 'document.pdf', {
type: 'application/pdf' // Correct MIME type for PDF
});
formData.append('file', file);Examples
Attempting PDF Operation on Image
Request:
# Trying to split an image file (not supported)
curl -X POST https://api.scan-documents.com/v1/pdf-operations/split \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "input=file_image123"Response:
{
"type": "https://scan-documents.com/docs/errors/unsupported-file-type",
"title": "Unsupported File Type",
"status": 415,
"message": "PDF operations require a PDF file. The provided file is an image."
}Uploading Unsupported Format
Request:
# Uploading a .docx file (not supported)
curl -X POST https://api.scan-documents.com/v1/files \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@document.docx"Response:
{
"type": "https://scan-documents.com/docs/errors/unsupported-file-type",
"title": "Unsupported File Type",
"status": 415,
"message": "The file type 'docx' is not supported. Supported types: pdf, png, jpg, jpeg, webp, tiff"
}Best Practices
-
Validate Before Upload: Check file types on the client side before uploading to provide immediate feedback to users.
-
Handle Errors Gracefully: Provide helpful error messages to users when they upload unsupported files:
try {
const response = await uploadFile(file);
} catch (error) {
if (error.status === 415) {
showError('Please upload a supported file type (PDF, PNG, JPEG, WebP, or TIFF)');
}
}- Provide Conversion Options: If users frequently need to convert files, consider integrating a file conversion service before uploading.
Related Errors
- Validation Error - Invalid request parameters
- Not Found - Resource doesn't exist