It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage
Highlighted

how to update status in defect using jira rest api

Hi Team,

I am having requirement to automate Defect Status update.

we are using below Rest API in order to update defect status.

 http://localhost:8080/rest/api/2/issue/{defectid}/

using PUT method

Payload :

 {
"expand": "renderedFields,names,schema,operations,editmeta,changelog,versionedRepresentations",
"fields": {
"issuetype": {
"description": "A problem which impairs or prevents the functions of the product.",
"name": "Bug",
"subtask": false
},
"description": "laksh12 defect updated",
"project": {
"id": "31266",
"key": "COOKIE",
"name": "COOKIE"
},
"summary": "updated12 defect summary",
"priority": {
"name": "High",
"id": "2"
},
"status":"3"
}
}

Response:

i am getting below error,

{
"errorMessages": [],
"errors": {
"status": "Field 'status' cannot be set. It is not on the appropriate screen, or unknown."
}
}

Kindly do the needful.

Thanks in advance.

1 comment

did u try to change the status number you have choose ? 

It is like the number choosen is wrong

Hi LostIn,

 

Thanks for your reply.

Can you please guide me what is the actual status request need to set.

We are passing the request for failed belongs to 2 and 

passed belongs to 1

actually i am using this request

"status":"3".  

Can you please share what is the valid json payload request for update the defect status.

it's seems that the integer you choose for the status is wrong. I mean, 3 is not a setable status. Can you use an API which can give u number available ? 

 

I mean for exemple, i use a get with this API api/2/issue/issueid/transitions

oRequest.Open("GET", "http://XXXX/rest/api/2/issue/" & id & "/transitions"

to get available transition choice and integer equivalent for those transition.

 

Then i can use a POST with the same API to change my issue transition state.

oRequest.Open("POST", "http://XXXX/rest/api/2/issue/" & id & "/transitions")

and then when i send my data

oRequest.Send(data)

I put this integer in, for example it give this

"expand": "transitions",
"transitions": [

{
"expand": "transitions",
"transitions": [
{
"id": "41",
"name": "Start Prepa",
"to": {
"self": "http://vld-jira:8080/rest/api/2/status/10227",
"description": "",
"iconUrl": "http://vld-jira:8080/images/icons/statuses/generic.png",
"name": "In Preparation",
"id": "10227",
"statusCategory": {
"self": "http://vld-jira:8080/rest/api/2/statuscategory/4",
"id": 4,
"key": "indeterminate",
"colorName": "yellow",
"name": "In Progress"
}}]}

 

Those are for example integer i have to use for issue transition, logically i was using 1,2,3,4 but in fact number are completely illogical.

'41 : Start Prepa
'401 : send mail
'151 : start work
'171 : Cancel
'371 : back to backlog

Thanks LostInMadness Forever for your reply, i am getting below error,

{
"errorMessages": [
"Missing 'transition' identifier"
],
"errors": {}
}

Can you please guide me.

Comment

Log in or Sign up to comment
TAGS

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you