move_test_cases_to_folder
Move test cases into an existing Jira/Zephyr folder by explicit case keys or from a source folder, reporting failed moves.
Instructions
Move test cases into another folder — one partial PUT /testcase/{key} per case that changes only the folder field. Select the cases with EITHER testCaseKeys OR fromFolder (resolved by GET /testcase/search on folder = ""): exactly one of the two, checked before any request. fromFolder matches that folder EXACTLY — cases in its subfolders are not included, and an existing but empty fromFolder moves nothing. The folder MUST already exist — the API never creates folders implicitly (use create_folder first). The TARGET folder is NOT checked before the requests: a path that does not exist still issues one PUT per case, every one of them fails with 400 and the call resolves with movedCount 0 — always read failed[], since the returned folder only echoes what was asked for. Folder paths are case-sensitive and the root "/" is not a valid target (400 "The value / was not found for field folder"), so a case cannot be moved out of all folders here. Duplicate testCaseKeys are de-duplicated: each case is moved once and movedCount counts distinct cases. maxCases caps both selection modes. A failing case does not abort the rest — it is reported in failed. Only the folder field is written (script, step ids, version, labels, status, priority, owner, objective and precondition are preserved) and moving is reversible (move them back the same way). De-duplication is by EXACT string: keys are neither trimmed nor upper-cased, so "PROJ-T1" and "proj-t1" are two candidates and the second one simply fails with 404 on this case-sensitive API. movedCount counts successful writes, so a case already sitting in the target folder counts as moved. maxCases is applied AFTER the duplicates are removed, and note appears only when something needs explaining (cap truncation, ignored duplicates) — a clean full move and an empty fromFolder both return no note. A fromFolder path that does not exist is different from an empty one: the underlying search fails with 400 "Value(s) not found for field folder". Each failed[] entry is { key, error }. Returns { folder, movedCount, moved, failed?, note? }.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| folder | Yes | Target folder: full path from the root starting with "/", e.g. "/Regression/Payments"; it must already exist and "/" itself is rejected by the API | |
| maxCases | No | Safety cap on how many cases one call moves, applied in BOTH modes: the fromFolder search stops there and a longer testCaseKeys list is truncated to its first distinct keys (default 200, integer >= 1) | |
| fromFolder | No | Move every case whose folder is EXACTLY this path (starting with "/"); subfolders are not included | |
| projectKey | No | Jira project key for the fromFolder search, e.g. "PROJ"; defaults to ZEPHYR_DEFAULT_PROJECT_KEY. Ignored with testCaseKeys, where each key carries its own project | |
| testCaseKeys | No | Explicit list of test case keys to move, e.g. ["PROJ-T1", "PROJ-T2"]; duplicates are ignored |