taiga-back
taiga-back copied to clipboard
API: User Stories Bulk Milestone Update
Do you want to request a feature or report a bug?
I want to report a bug.
What is the current behavior?
The current behaviour is that I cannot send user stories to the backlog via the API.
If the current behavior is a bug, please provide the steps to reproduce.
I am trying to send some user stories to the backlog, using the API. So I post the dataset included below to
.../api/v1/userstories/bulk_update_milestone
After looking into the database, the user stories in the backlog seem to have an empty string as the target milestone. So my dataset in my experiments is this:
{ "bulk_stories": [ { "order": 1, "us_id": 132 }, { "order": 2, "us_id": 133 }, { "order": 3, "us_id": 134 }, { "order": 4, "us_id": 135 }, { "order": 5, "us_id": 136 }, { "order": 6, "us_id": 141 }, { "order": 7, "us_id": 142 } ], "milestone_id": null, "project_id": 8 }
I tried different variants for "milestone_id", like "", or "null", but always end up with a 400 Bad Request and the error message that I need to supply a value for the milestone_id.
My understanding is that there might be a flaw in the JSON specification and/or the API which does not allow to distinguish between passing a 'null' value and omitting the value, which leads to the current situation.
What is the expected behavior?
The expected behaviour is that the milestone attribute of the user stories gets cleared, putting the user stories into the backlog.
Is it happening in taiga.io or in your own instance?
This happens on my own instance.
What browser/version are you using?
I am trying to make this change via an API call which I issue with the help of the 'requests' library.
Are there any console errors (Ctrl + F12) in red?
n/a
@muellert the milestone_id
was thought as a required field (https://taigaio.github.io/taiga-doc/dist/api.html#user-stories-bulk-update-milestone), in fact it's an explicit endpoint to set a milestone. We'll evaluate to change it.
Currently for moving a US from a milestone to the backlog you must make a PATCH
request to the US endpoint individually /api/v1/userstories/{us_id}
with the payload:
backlog_order: {order}
milestone: null
version: {new_version}
You must indicate the order in the backlog (could be '0' if you want it to be the first one) and the version number (https://taigaio.github.io/taiga-doc/dist/api.html#_occ_optimistic_concurrency_control).
Thank you for your feedback
How about adding an optional parameter to the JSON: "move_to_backlog": true|false If present and true, the user stories would be moved to the backlog, and the milestone parameter would be ignored. Alternative idea: Allow the milestone parameter to contain a string, fixed as "backlog"?
I have tried your suggestion, but get a 400 on that one with no further explanation. My code looks like this:
patch_url = self.api + '/userstories/%d' % int(us['id'])
data='''{
"backlog_order": %d,
"milestone": null,
"version": %d
}''' % (order, int(us['version']) + 1)
r = requests.patch(patch_url, data=data)
After that, r.status_code == 400.
@muellert you must use the current userstory version in the params, otherwise give you a 400 Bad request. Check https://taigaio.github.io/taiga-doc/dist/api.html#_occ_optimistic_concurrency_control.