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 vote

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!

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

64 views 0 5
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