0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Backlog API Character Limits (Tested July 2025)

Last updated at Posted at 2025-07-29

One the tools we're using was hit by a character limit error when posting comments to backlog through the API. The official docs don't spell them out, and most articles on the topic are pretty old.

So, I wrote a simple Google Apps Script to test Backlog API endpoints with oversized text and see what would break.

The Results

Here are the confirmed limits and the exact error messages you'll get. It's also handy to know the API can reply in either Japanese or English depending on Nulab account settings.

1. Add Issue

  • Endpoint: POST /api/v2/issues

  • Fields:

    summary

    • Limit: 255 characters
    • Error Response Examples:
      {"errors":[{"message":"件名は1文字以上255文字以下で入力してください。","code":7,"moreInfo":""}]}
      {"errors":[{"message":"The Subject must be no shorter than 1 and no longer than 255.","code":7,"moreInfo":""}]}
      

    description

    • Limit: 100,000 characters

    • Error Response Examples:

      {"errors":[{"message":"詳細は100,000文字以下で入力してください。","code":7,"moreInfo":""}]}
      {"errors":[{"message":"The Description must be no longer than 100,000 characters.","code":7,"moreInfo":""}]}
      

2. Add Comment

  • Endpoint: POST /api/v2/issues/:id/comments

  • Fields:

    content

    • Limit: 50,000 characters

    • Error Response Examples:

      {"errors":[{"message":"コメントは50,000文字以下で入力してください。","code":7,"moreInfo":""}]}
      {"errors":[{"message":"The Comment must be no longer than 50,000.","code":7,"moreInfo":""}]}
      

Methodology

I made a simple GAS script to check.

Click to see
/**
 * Backlog APIの文字数制限をテストするためのGoogle Apps Scriptです。
 * * 実行前の注意点:
 * 1. devオブジェクト内のプレースホルダーの値を実際のデータに置き換えてください。
 * 2. 実行するには、ツールバーから `runAllTests` 関数を選択し、「実行」をクリックしてください。
 * 3. ログ(表示 > ログ)でAPIのレスポンスを確認してください。
 */

// --- 設定: これらの値をあなたの情報に置き換えてください ---
const dev = {
  backlog_url: 'https://your-space.backlog.jp',
  backlog_apikey: 'YOUR_API_KEY_HERE',
  project_id: "12345", // Backlogスペースの有効なプロジェクトID
  issue_type_id: "67890", // プロジェクトの有効な課題種別ID
  priority_id: 3, // 有効な優先度ID(例: 3は「中」)
  test_issue_id_or_key: 'PROJ-123' // コメントを追加するための既存の課題IDまたはキー
};
// --- 設定はここまで ---


/**
 * すべての文字数制限テストを実行するメイン関数です。
 */
function runAllTests() {
  Logger.log('--- Backlog API 文字数制限テストを開始します ---');
  
  testSummaryLimit();
  Utilities.sleep(1000); // レート制限を考慮して1秒間一時停止します

  testDescriptionLimit();
  Utilities.sleep(1000); // 1秒間一時停止します

  testCommentLimit();

  Logger.log('--- 全てのテストが完了しました。詳細はログを確認してください。 ---');
}

/**
 * 課題の件名(summary)の255文字制限をテストします。
 * 256文字の件名で課題を作成しようとします。
 */
function testSummaryLimit() {
  Logger.log('\n[テスト 1] 課題の件名(255文字)の制限をテスト中...');
  const endpoint = '/api/v2/issues';
  const oversizedSummary = generateString(256); // 制限は255文字なので、256文字でテストします

  const payload = {
    'projectId': dev.project_id,
    'issueTypeId': dev.issue_type_id,
    'priorityId': dev.priority_id,
    'summary': oversizedSummary,
    'description': 'これは件名の文字数制限のテストです。'
  };

  postToBacklog(endpoint, payload);
}

/**
 * 課題の詳細(description)の100,000文字制限をテストします。
 * 100,001文字の詳細で課題を作成しようとします。
 */
function testDescriptionLimit() {
  Logger.log('\n[テスト 2] 課題の詳細(100,000文字)の制限をテスト中...');
  const endpoint = '/api/v2/issues';
  const oversizedDescription = generateString(100001); // 制限は100,000文字です

  const payload = {
    'projectId': dev.project_id,
    'issueTypeId': dev.issue_type_id,
    'priorityId': dev.priority_id,
    'summary': 'テスト: 詳細の制限',
    'description': oversizedDescription
  };

  postToBacklog(endpoint, payload);
}

/**
 * コメント(content)の50,000文字制限をテストします。
 * 50,001文字のコメントを追加しようとします。
 */
function testCommentLimit() {
  Logger.log('\n[テスト 3] コメント(50,000文字)の制限をテスト中...');
  const endpoint = `/api/v2/issues/${dev.test_issue_id_or_key}/comments`;
  const oversizedContent = generateString(50001); // 制限は50,000文字です

  const payload = {
    'content': oversizedContent
  };

  postToBacklog(endpoint, payload);
}


/**
 * Backlog APIにPOSTリクエストを送信するヘルパー関数です。
 * @param {string} endpoint 呼び出すAPIエンドポイント(例: '/api/v2/issues')。
 * @param {Object} payload リクエストボディで送信されるデータ。
 */
function postToBacklog(endpoint, payload) {
  const url = `${dev.backlog_url}${endpoint}?apiKey=${dev.backlog_apikey}`;
  
  const options = {
    'method': 'post',
    'contentType': 'application/x-www-form-urlencoded',
    'payload': payload,
    'muteHttpExceptions': true // エラー時にスクリプトが停止するのを防ぎ、ログに記録できるようにします
  };

  try {
    const response = UrlFetchApp.fetch(url, options);
    const responseCode = response.getResponseCode();
    const responseBody = response.getContentText();

    Logger.log(`  > HTTPステータスコード: ${responseCode}`);
    Logger.log(`  > レスポンスボディ: ${responseBody}`);

    if (responseCode === 400) {
      Logger.log('=====結果:登録失敗====='); // 400エラーはテスト成功とみなす
    } else {
      Logger.log('=====結果:登録成功====='); // 400以外のコードはテスト失敗とみなす
    }

  } catch (e) {
    Logger.log(`  > 予期せぬエラーが発生しました: ${e.message}`);
    Logger.log('=====結果:登録失敗====='); // スクリプト自体のエラー
  }
}

/**
 * 指定された長さの文字列を生成するヘルパー関数です。
 * @param {number} length 生成する文字列の長さ。
 * @return {string} 指定された長さの文字列。
 */
function generateString(length) {
  // テスト文字列として単純な「a」を使用します。
  return 'a'.repeat(length);
}


The End

That's it! These tests confirm the limits. Now you can build your error handling with confidence. Hope this helps someone out!

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?