Hi,
I need to re-open an incident from my application using JIRA REST API. Can any one help me on this?
Any help regarding the same is highly appreciated.
Regards
Praveen.
Community moderators have prevented the ability to post new answers.
@praveen ,
To re-open an issue via code, you need to do two things
1. Ensure the workflow has a transition from closed to open/reopened/whereever
2. Run the workflow transition.
through jira rest api :
/rest/api/2/issue/{issueIdOrKey}/transitions?expand=transitions.fields
transistions.field is used if any field is configured in transition.
Hi Nitram/ Dipti,
When I give the url as http:<servername>/rest/api/2/issue/JIRA-1000/transitions?expand=transitions.fields in the browser it has me returned me a json like this.
{"expand":"transitions","transitions":[]}
Does this means there are no fields I can set? How can I add fields to the transition screen?
Regards
Praveen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I will post a sample code if you are new to rest, wait for few mins
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI,
jus give this much to get the transitions of that issue
once you got the transitions, you will come to know whether the issue is capable of re-opening.
then if you want to do a post call, then supply a data like this to your post call request, then it will update JIRA and will give you a response
{ "update": { "comment": [ { "add": { "body": "Bug has been fixed." } } ] }, "transition": { "id": "5" } }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Praveen,
Please look into this link, https://docs.atlassian.com/jira/REST/latest/#idp1811072
This will help you.
You need to call the correct transition, then you will be able to reopen the incident.
Hope this helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
/rest/api/2/issue/{issueIdOrKey}/transitions?expand=transitions.fields, this is a post call
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Perform a transition on an issue. When performing the transition you can udate or set other issue fields.
The fields that can be set on transtion, in either the fields parameter or the update parameter can be determined using the /rest/api/2/issue/{issueIdOrKey}/transitions?expand=transitions.fields resource. If a field is not configured to appear on the transition screen, then it will not be in the transition metadata, and a field validation error will occur if it is submitted.
acceptable request representations:
{ "update": { "comment": [ { "add": { "body": "Bug has been fixed." } } ] }, "fields": { "assignee": { "name": "bob" }, "resolution": { "name": "Fixed" } }, "transition": { "id": "5" } }
available response representations:
Returned if the transition was successful.
If there is no transition specified.
The issue does not exist or the user does not have permission to view it
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nitram,
Thanks for the quick response. I've tried this, but when I try to open the link (http:<servername>/rest/api/2/issue/JIRA-1000/transitions?expand=transitions.fields " from browser it says "Unable to download transitions from blrkec6347s. Unable to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later".
When I try to invoke the Url from my code by creating an object of HTTP web request it's failing with the below error.
"invalid uri the authority/host could not be parsed"
The code i'm using to create the HTTP web request object is as below.
HttpWebRequest request = WebRequest.Create(url) asHttpWebRequest;
where url is as above.
Can you let me know what i might be missing?
Thanks and Regards
Praveen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Check this solution,
use REST::Client;
use MIME::Base64;
use JSON ;
#username and password
my $user = 'username';
my $pass = 'password';
#The basic use case
my $client = REST::Client->new();
#A host can be set for convienience
$client->setHost('url');
my $headers = { Authorization => 'Basic '. encode_base64($user . ':' . $pass)};
my $jsonparams ={ "update": { "comment": [ { "add": { "body": "Bug has been fixed." } } ] }, "transition": { "id": "5" } };
$client->Post( '/rest/api/2/issue/JIRA-1000/transitions',$jsonparams , $headers );
if( $client->responseCode() eq '200' ){
print "Updated\n";
}
# print the result
print $client->responseContent() . "\n";
# to convert the data into a hash, use the JSON module
my $res_data = from_json( $client->responseContent() );
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nitram,
Thanks for clarifying me. This is what exactly I'm doing, but I've posted only one line of my code. Any idea why i'm getting that "invalid uri the authority/host could not be parsed" error.
Regards
Praveen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Actually from a browser you will not be able to call a post method without sending any data whatever it needs, thats why you are getting error, from your code if your trying then you need to do the following,
I have tried the rest-api using perl
So what I did is
1) I sent my username and password and I encoded it,
2) I set the url
3) using the client I called the respective post by sending the data in json format.
4) I received a response from my server.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.