JIRA Cloud REST API - PUT FixVersion failed Edited

I want to use JIRA Cloud REST API put fixversion to many issues.

I read JIRA Cloud REST API doc and used code litke this

curl -X PUT --data "{ \"update\": { \"fixVersion\": [ { \"add\": \"0.0.3\" } ] } }"  https://$USERNAEM:$PASSWORD@$net/rest/api/2/issue/$issueid 
 % Total % Received % Xferd Average Speed  Time   Time  Time Current
Dload Upload Total Spent Left Speed
100 54 0 0 100 54 0 52 0:00:01 0:00:01 --:--:-- 53

but nothing happened

擷取.PNG

I get info form /{issueIdOrKey}/editmeta

  "fixVersions": {
"required": false,
"schema": {
"type": "array",
"items": "version",
"system": "fixVersions"
},
"name": "Fix Version\/s",
"key": "fixVersions",
"operations": [
"set",
"add",
"remove"
],
"allowedValues": [
{
"self": "https:\/\/eastek-ezcam.atlassian.net\/rest\/api\/2\/version\/18300",
"id": "18300",
"name": "0.0.0",
"archived": false,
"released": false,
"projectId": 11000
},
{
"self": "https:\/\/eastek-ezcam.atlassian.net\/rest\/api\/2\/version\/18301",
"id": "18301",
"name": "0.0.1",
"archived": false,
"released": false,
"projectId": 11000
}
]
},

 Is '"required": false' the reason I failed  ?

How do I let "required": true ?

-------------------------------Update(8/28)------------------------------

I added '-H "Content-Type: application/json"' 

#!/bin/sh
curl -u $USERNAEM:$PASSWORD -X PUT -H "Content-Type: application/json" --data '{"update": {"fixVersions": [{"add": [{ "name": "0.0.2"}]}]}}' $URL

and got error message

{"errorMessages":[],"errors":{"fixVersions":"Could not find valid 'id' or 'name' in version object."}}

 

2 answers

1 accepted

0 votes
Accepted answer

Looks to me like your curl command is wrong, not the data.  Try using it as documented, with -u for username and password, and the url as a distinct item.

Also, what errors are you getting?  "Nothing happened" does not tell us anything.

Thank for your help.

I said  "Nothing happened" because it didn't gave me any errors likes "http error code"  or "crul error".

I use 

curl -u $USERNAEM:$PASSWORD -X PUT --data "{ \"update\": { \"fixVersion\": [ { \"add\": \"0.0.3\" } ] } }"  https://$net/rest/api/2/issue/$issueid 

and get only this.

 % Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 54 0 0 100 54 0 50 0:00:01 0:00:01 --:--:-- 51

It still failde for me putting fixversion to my issue. :(

If it's getting nothing back at all, that is very odd.  We can see it's not.

Can you visit that url in a browser?  Does that give you any response at all?

Yes. I can visit url in a browser.

I also can use api to get infomation from the same url.

Is the reason that I'm not the owner of JIRA?

I'm one of the team members.

If the url you intend to reach gives you data, but your curl does not, then there's something wrong in the curl invocation.

My guess is that your code is not expanding the $net and/or $issueid variables in the way you expect.

You have not given the context of where that line is running.  Maybe show us the script it is in?

My test scritp

#!/bin/sh
# -*- coding: utf-8 -*-
#Usage: ./add_version.sh fixversion
USERNAEM=''
PASSWORD=''
team=''
version=$1
jira_keys=`cat jira_keys`

for KEY in $jira_keys
do
curl -X PUT --data "{ \"update\": { \"fixVersion\": [ { \"add\": \"$version\" } ] } }" https://$USERNAEM:$PASSWORD@$team.atlassian.net/rest/api/2/issue/$jira_keys
done

@Nic Brough [Adaptavist] 

I update the error message on my post.

I find the doc from here and it work for me.

Thanks!

@Sam Hall

Can you help me?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,772 views 18 21
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you