taskadapter / redmine-java-api

Redmine Java API
Apache License 2.0
269 stars 162 forks source link

allow to unset assigned_to_id of issues #306

Closed akohlbecker closed 6 years ago

akohlbecker commented 6 years ago

The assigned_to_id of an existing issue can not be unset:

issue.setAssigneeId(null);

will cause the Transport to send a null value to the REST API:

{
  "issue":
  {
   "assigned_to_id": null
   }
}

but Redmine (v.3.3.6) ignores this. The only value which causes the issue service to reset the assigned_to_id is an empty string:

{
  "issue":
  {
   "assigned_to_id": ""
   }
}
alexeyOnGitHub commented 6 years ago

@akohlbecker thank you for reporting this. I do not actively work on this project anymore. if you can submit a PR with a fix that would be in line with the current architecture, I can review & merge.

alexeyOnGitHub commented 6 years ago

closing since no one volunteered to work on this issue. in general, the API was not intended to erase fields (historical reasons). this can be implemented, but needs to be done in a backward-compatible manner , as a general solution for all fields, not just one

eticco commented 5 years ago

We have found today the same problem when I migrated from Redmine v3.1.2 (unset assignee_to_id from Redmine Java API worked fine) to v3.4.11 (assigned_to_id can't be unset by API). Our workaround has been to change the addIfSet method in the RedmineJSONBuilder class of the Redmine Java API. I share it for if this may help someone


private static void addIfSet(JSONWriter writer, String jsonKeyName, PropertyStorage storage, Property<?> property) throws JSONException {
    if (storage.isPropertySet(property)) {
        writer.key(jsonKeyName);
        writer.value(storage.get(property) != null ? storage.get(property) : "");
    }
}
Glideh commented 3 years ago

This seems to work now on Redmine 4.1.0 with "assigned_to_id": ""