JIRA Cloud REST API - PUT FixVersion failed

eastek_claire August 23, 2017

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
Answer accepted
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 24, 2017

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.

eastek_claire August 24, 2017

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. :(

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 24, 2017

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?

eastek_claire August 24, 2017

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.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 24, 2017

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?

eastek_claire August 24, 2017

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
eastek_claire August 27, 2017

@Nic Brough -Adaptavist- 

I update the error message on my post.

eastek_claire August 28, 2017

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

Thanks!

0 votes
eastek_claire August 23, 2017

@Sam Hall

Can you help me?

Suggest an answer

Log in or Sign up to answer