Possible Causes:
Solutions:
Authorization: Bearer YOUR_TOKENTest Command:
# Test if your token format is correct
curl -v -X POST "$CONFLUENCE_API_ENDPOINT" \
-H "Authorization: Bearer $CONFLUENCE_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"spaceId":"TEST","parentId":"123","pageTitle":"Test","content":"# Test"}'
Possible Causes:
Solutions:
Debug Steps:
exp (expiration) claimPossible Causes:
Solutions:
Possible Causes:
overwrite parameter set to falseSolutions:
overwrite: true to update existing pageparentId is correctExample Fix:
{
"spaceId": "DOCS",
"parentId": "123456789",
"pageTitle": "API Reference",
"content": "# Updated Content",
"overwrite": true // Set to true to update
}
Possible Causes:
spaceIdparentIdSolutions:
Verify Space and Page:
# Check if space exists
curl -X GET "https://your-site.atlassian.net/wiki/api/v2/spaces?keys=DOCS" \
-H "Authorization: Bearer YOUR_CONFLUENCE_TOKEN"
# Check if parent page exists
curl -X GET "https://your-site.atlassian.net/wiki/api/v2/pages/123456789" \
-H "Authorization: Bearer YOUR_CONFLUENCE_TOKEN"
Possible Causes:
Solutions:
spaceId, parentId, pageTitle, content)Validation Example:
function validatePayload(payload) {
const required = ['spaceId', 'parentId', 'pageTitle', 'content'];
for (const field of required) {
if (!payload[field]) {
throw new Error(`Missing required field: ${field}`);
}
}
if (payload.content.trim().length === 0) {
throw new Error('Content cannot be empty');
}
return true;
}
Possible Causes:
Solutions:
Retry with Exponential Backoff:
async function retryRequest(fn, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
try {
return await fn();
} catch (error) {
if (error.status !== 500 || i === maxRetries - 1) {
throw error;
}
await sleep(1000 * Math.pow(2, i));
}
}
}
Isolate issues from your code by testing with curl:
curl -v -X POST "$CONFLUENCE_API_ENDPOINT" \
-H "Authorization: Bearer $CONFLUENCE_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"spaceId": "DOCS",
"parentId": "123456789",
"pageTitle": "Test Page",
"content": "# Test\n\nThis is a test.",
"overwrite": false
}'
The -v flag shows full request/response details.
cURL:
curl -v -X POST "..." # Shows headers and response
Node.js (axios):
axios.interceptors.request.use(request => {
console.log('Request:', JSON.stringify(request, null, 2));
return request;
});
axios.interceptors.response.use(
response => {
console.log('Response:', JSON.stringify(response.data, null, 2));
return response;
},
error => {
console.error('Error:', JSON.stringify(error.response?.data, null, 2));
return Promise.reject(error);
}
);
Ensure your JSON is valid:
# Linux/macOS
echo '{"spaceId":"DOCS"}' | jq .
# Or use an online JSON validator
exp claim)iat claim)Make sure headers are correct:
console.log('Headers:', {
'Authorization': `Bearer ${token.substring(0, 20)}...`, // Never log full token
'Content-Type': 'application/json'
});
If you're getting errors, try with minimal content:
{
"spaceId": "DOCS",
"parentId": "123456789",
"pageTitle": "Test",
"content": "# Test",
"overwrite": false
}
Problem: Certificate verification fails
Solution:
// Development only - NEVER in production!
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
Better solution: Fix certificate chain or use proper CA certificates.
Problem: Request times out
Solution:
const axios = require('axios');
const instance = axios.create({
timeout: 30000, // 30 seconds
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
}
});
If behind a corporate proxy:
export HTTP_PROXY=http://proxy.example.com:8080
export HTTPS_PROXY=http://proxy.example.com:8080
Possible Causes:
Solutions:
Problem: Too many requests
Solution:
const pLimit = require('p-limit');
const limit = pLimit(3); // Max 3 concurrent requests
const promises = pages.map(page =>
limit(() => importToConfluence(page))
);
await Promise.all(promises);
If you're still experiencing issues:
Check Documentation:
Gather Information:
Contact Support: