We've sucessfully been using api-group-project-versions/#api-rest-api-2-version-id-put to synchronize version information (name, startDate, releaseDate, description) across multiple projects.
However, I get a 400 when I try and remove a startDate, either by omitting it, or by setting to "", "0". So my question is, how can I remove a startDate from a fixVersion?
example 1: PUT https://our-jira-server/rest/api/2/version/53756
--> w/ empty startDate == 400
{
"description": "An excellent version",
"name": "New Version 1",
"startDate" : "",
"releaseDate": "2010-07-06"
}
example 2: PUT https://our-jira-server/rest/api/2/version/53756
--> w/ 0 as startDate == 400
{
"description": "An excellent version",
"name": "New Version 2",
"startDate" : 0,
"releaseDate": "2010-07-06"
}
example 3: PUT https://our-jira-server/rest/api/2/version/53756
--> omitting startDate == startDate left unchanged (obviously)
{
"description": "An excellent version",
"name": "New Version 3",
"releaseDate": "2010-07-06"
}
Hi @Leon -- Welcome to the Atlassian Community!
I recall seeing another post suggesting setting to the minimum date value, or null, to clear a date/time field with JSON. Have you tried either of those?
Best regards,
Bill
Bill you wonderful man! That did the trick - thank you!
{
"description": "An excellent version",
"name": "New Version 3",
"releaseDate": "2010-07-06",
"startDate": null
}
Note to others that I'm working in Python, and that json.dump() will convert None to a json null
payload = json.dumps( {
"name": "New Version 3",
"description": "Wow, look at me",
"startDate": None, # <----- will be converted to json null
"releaseDate": "2020-07-22"} )
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Leon, I am glad that worked for you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Bill Sheboy
I am also using Json syntax for updating fields in my Jira automation Action "Send Web request" in which I create an issue.
I want to update several fields from the triggerIssue. But some fields are empty in the triggerissue and therefore no value can be set and the web request is not successful.
{
"fields":{
"customfield_10853": {"value":"{{issue.customfield_10853}}"},
"customfield_10683": {"value":"{{issue.customfield_10683}}"},
"customfield_10682": {"value":"{{issue.customfield_10682}}"}
}
}
When one of the customfields in the triggerissue is empty I get an error because no value can be set in the issue.
But when the customfield of the trigger issue is empty the customfield of the updated issue should be also empty.
I know that I can set a customfield to empty by using the following code:
{
"fields":{
"customfield_10853": null,
"customfield_10683": null,
"customfield_10682": null
}
}
I was wondering If can solve the problem by using a default value which is "null":
Like this:
{
"fields":{
"customfield_10853": {"value":"{{issue.customfield_10853|null}}"},
"customfield_10683": {"value":"{{issue.customfield_10683|null}}"},
"customfield_10682": {"value":"{{issue.customfield_10682|null}}"}
}
}
But it does not work. Do you have any ideas?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Perhaps try using conditional logic for each field: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-conditional-logic/
For example,
{{#if(not(exists(issue.customfield_10853)))}}none{{/}}{{issue.customfield_10853}}
This would check if the value does-not-exist, returning "none" for that, and concatenate the field value on the end (to handle the opposite case).
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Bill Sheboy
Do you mean like this?
{
"fields": {
"duedate": "{{if(not(exists(issue.customfield_10015)))}} none {{/}}{{issue.customfield_10015}}"
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Almost...should there be spaces around "none"? And does none need the quotation marks around it?
I have not tried that for this type of field so please test it to confirm, possibly adding two specific conditions: one for the value empty and one for the value not empty.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.