I am trying to add Fix Version to an issue via a curl request. That particular jira Issue page does have "Fix Version/s:" field. Also the create Issue screen contains the field "Fix Version/s:". But somehow it is not letting me to add the fix version.
Honestly speaking the Jira Rest API is not that user-friendly. Its pretty tough to understand what the API needs. I might be wrong, in which case I seek your guidance.
Additionally if you could guide me how to achieve this same result using Jira Rest Java Client.
As per the documentation, The general structure of an update is field, array of verb-value pairs. For example:
{ "update": {
"field1": [ {"verb": value}, {"verb": value}, ...],
"field2": [ {"verb": value}, {"verb": value}, ...],
}}If I go by the above explanation then for my case of updating fixVersion the structure would look sth like :
{ "update": {
"fixVersions": [ {"add": "AB 2022.02.000"}]
}}So as per above format my request should be :
curl -D- -u ${ADMIN_USER}:${ADMIN_PASSWORD} -X PUT --data "{\"update\" : { \"fixVersions\" : [{\"add\":\"AB 2022.02.00\"}]}}" -H "Content-Type: application/json" https://jira2.company.com/rest/api/2/issue/ProjCode-12345If I execute above command I get below response :
{"errorMessages":[],"errors":{"fixVersions":"Field 'fixVersions' cannot be set. It is not on the appropriate screen, or unknown."}}
I looked for similar issues online and came across a couple of Atlassian community threads, but they didn't seem to help my cause.
Below are the different curl requests (along-with their response) that I have tried executing based on the suggestions that I came across :
Request #1 :
curl -D- -u ${ADMIN_USER}:${ADMIN_PASSWORD} -X PUT --data "{\"update\" : { \"fixVersions\" : {\"add\":{\"name\":\"AB 2022.02.000\"}}}}" -H "Content-Type: application/json" https://jira2.company.com/rest/api/2/issue/ProjCode-12345Response #1 :
{"errorMessages":["Can not deserialize instance of java.util.ArrayList out of START_OBJECT token\n at [Source: org.apache.catalina.connector.CoyoteInputStream@29848f08; line: 1, column: 15] (through reference chain: com.atlassian.jira.rest.v2.issue.IssueUpdateBean[\"update\"])"]}
Request #2 :
curl -D- -u ${ADMIN_USER}:${ADMIN_PASSWORD} -X PUT --data "{\"update\" : { \"fixVersions\" : {\"add\":[{\"name\":\"AB 2022.02.000\"}]}}}" -H "Content-Type: application/json" https://jira2.company.com/rest/api/2/issue/ProjCode-12345Response #2 :
{"errorMessages":["Can not deserialize instance of java.util.ArrayList out of START_OBJECT token\n at [Source: org.apache.catalina.connector.CoyoteInputStream@14c3752f; line: 1, column: 15] (through reference chain: com.atlassian.jira.rest.v2.issue.IssueUpdateBean[\"update\"])"]}
Request #3 :
curl -D- -u ${ADMIN_USER}:${ADMIN_PASSWORD} -X PUT --data "{\"update\" : { \"fixVersions\" : [{\"add\":[{\"name\":\"AB 2022.02.000\"}]}]}}" -H "Content-Type: application/json" https://jira2.company.com/rest/api/2/issue/ProjCode-12345Response #3 :
{"errorMessages":[],"errors":{"fixVersions":"Field 'fixVersions' cannot be set. It is not on the appropriate screen, or unknown."}}
Request #4 :
curl -D- -u ${ADMIN_USER}:${ADMIN_PASSWORD} -X PUT --data "{\"update\" : { \"fixVersions\" : [{\"add\":{\"name\":\"AB 2022.02.000\"}}]}}" -H "Content-Type: application/json" https://jira2.company.com/rest/api/2/issue/ProjCode-12345Response #4 :
{"errorMessages":[],"errors":{"fixVersions":"Field 'fixVersions' cannot be set. It is not on the appropriate screen, or unknown."}}