View Issue Details

IDProjectCategoryView StatusLast Update
0035668mantisbtapi restpublic2025-03-28 10:15
Reporterpikachurus Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status confirmedResolutionopen 
Product Version2.26.4 
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
}