Relationship Graph

Relationship Graph
related to related to child of child of duplicate of duplicate of

View Issue Details

IDProjectCategoryView StatusLast Update
0035668mantisbtapi restpublic2025-05-03 19:31
Reporterpikachurus Assigned Todregad  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version2.26.4 
Target Version2.27.2Fixed in Version2.27.2 
Summary0035668: can't change issue category to "no category" via rest api
Description

Hi!

trying to change issue category to "(no category)" via api by setting id to 0, but returns "Category not found":

Invoke-RestMethod : {"message":"Category '{\"id\":\"0\"}' not found.","code":

TagsNo tags attached.

Relationships

related to 0034683 closeddregad REST POST /issues allows creation of Issue when invalid Category is specified 

Activities

atrol

atrol

2025-03-27 10:39

developer   ~0070041

@pikachurus do you have set $g_allow_no_category = ON;?
If yes, does it work with version 2.26.3?

pikachurus

pikachurus

2025-03-28 09:13

reporter   ~0070042

yes, $g_allow_no_category = ON;

I'll be able to check with 2.26.3 in a few days.

btw, in web interface i can change category to 'no category' with no problem.

dregad

dregad

2025-03-28 10:15

developer   ~0070044

The reported behavior is reproducible in 2.26.4 and the latest master branch with the request below. It appears to be a regression introduced by the fix for 0034683 - in 2.26.3 the same request does clear the category.

PATCH http://localhost/mantis/api/rest/issues/{{id}}
Authorization: {{token}}
Content-Type: application/json

{
  "category": {
    "id": 0
  }
}

Response code: 404 (Category '{"id":0}' not found.); Time: 71ms (71 ms); Content length: 92 bytes (92 B)

For the record, with MantisBT 2.26.4 and later it is currently possible to unset the category with the following payload. At this time I am not sure whether this is actually correct or even intentional, but at least for now you can use that as a workaround.

{
  "category": null
}
dregad

dregad

2025-04-21 14:38

developer   ~0070179

PR https://github.com/mantisbt/mantisbt/pull/2136

Related Changesets

MantisBT: master f97ee460

2025-03-28 20:54

dregad


Details Diff
Fix regression in mci_get_category_id()

REST API was not allowing to unset the Category when updating an Issue
with $g_allow_no_category = ON with a payload `{"category": {"id": 0}}`.

Regression in mci_get_category_id() function, introduced by commit
656f93eebaf033f4b5bf34f17487db6346f12d8a (Issue 0034683).

Fixes 0035668
Affected Issues
0034683, 0035668
mod - api/soap/mc_api.php Diff File

MantisBT: master e66c63e5

2025-04-20 12:16

dregad


Details Diff
Add tests for REST API update issue Category

Issue 0035668
Affected Issues
0035668
add - tests/rest/RestIssueUpdateCategory.php Diff File

MantisBT: master 1ccc4205

2025-04-20 12:20

dregad


Details Diff
Fix incorrect behavior in mci_get_category_id()

Now properly throws a ClientException when the given Category Id is
not an integer.

Fixes 0035668
Affected Issues
0035668
mod - api/soap/mc_api.php Diff File

MantisBT: master-2.27 01f3d24e

2025-04-20 12:20

dregad


Details Diff
Fix regression in mci_get_category_id()

REST API was not allowing to unset the Category when updating an Issue
with $g_allow_no_category = ON with a payload `{"category": {"id": 0}}`.

Regression in mci_get_category_id() function, introduced by commit
656f93eebaf033f4b5bf34f17487db6346f12d8a (Issue 0034683).

Fixes 0035668

Backported from master branch (cherry picked commits f97ee460815ff14b31462d1da0a48405d0acb363 and
1ccc4205e50c23d47009073d85423d29c4cae449).
Affected Issues
0034683, 0035668
mod - api/soap/mc_api.php Diff File