Skip to content

How to Fix Confluence REST API Errors

DodaTech Updated 2026-06-24 2 min read

In this tutorial, you'll learn about How to Fix Confluence REST API Errors. We cover key concepts, practical examples, and best practices.

Confluence REST API returns 401 Unauthorized, 404 Not Found, or paginated results are incomplete. Authentication tokens, endpoint paths, and query parameters need correction.

The Wrong Way

const response = await fetch('/rest/api/content?limit=1000');

Requests without pagination handling return only the first 25 results by default. The limit=1000 is capped at 200 per page.

The Right Way

Step 1: Use proper authentication

# Basic Auth:
curl -u "username:api_token" \
  "https://your-domain.atlassian.net/wiki/rest/api/content"

# OAuth 2.0 (recommended):
curl -H "Authorization: Bearer <access_token>" \
  "https://your-domain.atlassian.net/wiki/rest/api/content"

Step 2: Handle pagination correctly

async function getAllPages(spaceKey) {
  let results = [];
  let start = 0;
  const limit = 50;

  while (true) {
    const resp = await fetch(
      `/rest/api/content?spaceKey=${spaceKey}&start=${start}&limit=${limit}`
    );
    const data = await resp.json();
    results = results.concat(data.results);
    if (data.results.length < limit) break;
    start += limit;
  }
  return results;
}

Step 3: Use the correct endpoint paths

# Latest API (v2):
# /wiki/api/v2/pages → paginated pages
# /wiki/api/v2/spaces → list spaces

# Legacy API:
# /rest/api/content → pages and blog posts
# /rest/api/space → spaces

v2 is the current API. Use it for new integrations.

Step 4: Handle rate limiting

// Add retry with exponential backoff
async function apiCall(url, retries = 3) {
  for (let i = 0; i < retries; i++) {
    const resp = await fetch(url);
    if (resp.status === 429) {
      const wait = Math.pow(2, i) * 1000;
      await new Promise(r => setTimeout(r, wait));
      continue;
    }
    return resp;
  }
}
API response: 347 pages fetched across 7 paginated requests, 0 rate limit hits.

Prevention

  • Always paginate API responses — never assume all results fit in one call.
  • Use API tokens instead of passwords for script authentication.
  • The API pagination pattern is the same one used in DodaZIP's cloud storage integration — batch fetching with cursor-based pagination.

Common Mistakes with rest api

  1. Placing the wildcard pattern first in case expressions, making all subsequent patterns unreachable
  2. Using head and tail instead of pattern matching, causing runtime errors on empty lists
  3. Forgetting that lazy evaluation defers computation until the value is forced, causing space leaks with unevaluated thunks

These mistakes appear frequently in real-world CONFLUENCE code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### What is the difference between Confluence REST API v1 and v2?

v2 is the current recommended version with consistent pagination, more intuitive endpoints (/api/v2/pages vs /rest/api/content), and better error messages. v1 is legacy but still supported. Migrate to v2 for new projects.

Why does my Confluence API return 403 Forbidden?

The API token does not have the required scopes. In OAuth 2.0, ensure your token includes scopes like read:confluence-content. In Basic Auth, the account must have at least View permission on the requested space.

What is the Confluence API rate limit?

Atlassian Cloud rate limits vary by plan: Free: 100 requests/min, Standard: 500/min, Premium: 1000/min. On-premise Confluence has no built-in rate limiting but may be subject to server-side throttling.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro