marvin_17392
11/14/2025, 4:11 AMAI Evy
11/14/2025, 4:11 AMAI Evy
11/14/2025, 4:11 AMmultipart/form-data body, not application/json. [(2) ]() This is a common cause of the 500 error.
Working Example:
javascript
import Retell from 'retell-sdk';
import fs from 'fs';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
async function main() {
try {
const formData = new FormData() ;
const fileContent = fs.readFileSync('./test.txt') ;
const fileBlob = new Blob([fileContent], { type: 'text/plain' }) ;
formData.append('knowledge_base_name', 'KB_Name') ;
formData.append('knowledge_base_files', fileBlob, 'FILE_NAME.txt') ;
const response = await fetch('<https://api.retellai.com/create-knowledge-base',> {
method: 'POST',
headers: {
'Authorization': `Bearer ${client.apiKey}`,
},
body: formData,
}) ;
if (!response.ok) {
const errorText = await response.text() ;
console.error('Error creating knowledge base:', errorText) ;
return;
}
const result = await response.json() ;
console.log('Knowledge base created successfully:', result) ;
} catch (error) {
console.error('Error:', error) ;
}
}
main() ;AI Evy
11/14/2025, 4:11 AMapplication/json instead of multipart/form-data [(2) ]()
2. Not properly formatting the knowledge_base_name as a string [(1) ]()
3. For URLs, ensure they're properly formatted as a JSON-serialized list of strings, for example: `"[' [(2) ]()
If you're still experiencing issues after verifying your request format, the Retell team may be working on knowledge base infrastructure issues. [(1) ]()
**AI Evy
11/14/2025, 4:11 AMAI Evy
11/14/2025, 4:11 AM