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

Groovy script to create or update jira issue using rest api

Ankita Sharma Jan 12, 2016

I need to write a groovy script in post function to create or update a jira issue using rest api

 

Please Help.

8 answers

Ankita Sharma Jan 14, 2016

Vasiliy, I am new to this code but on using it, I am unable to resolve HTTPContext. Even though I am using correct import statements, but it is not working for me :(

0 votes
Thanos Batagiannis [Adaptavist] Community Leader Jan 12, 2016

Ankita, is there a particular reason you want to use the rest api ?

0 votes
Ankita Sharma Jan 12, 2016

Thanos, i have to use rest api only. Please suggest me. Vasiliy, i have already checked this link. The code is not working for me within post function. Would it be possible for you to provide me with a very basic code?

0 votes
Nic Brough [Adaptavist] Community Leader Jan 12, 2016

I think Thanos is questioning the requirement. You already have direct access to the JIRA that your post-function is running in and do not need to use REST to talk to it. My guess is that you are writing code that updates another remote JIRA?

0 votes
Ankita Sharma Jan 14, 2016

yes right, I have access to JIRA but want to create issues within JIRA using REST API (REST APIs available for JIRA; https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-create-issue) within a post function with groovy script. Later i will use REST API of some other applications.

0 votes
Nic Brough [Adaptavist] Community Leader Jan 14, 2016

But why? When you're running a script, you have access to your JIRA. It's far faster, easier, flexible and more efficient to create them in the script.

0 votes
Thanos Batagiannis [Adaptavist] Community Leader Jan 14, 2016

Ankita, The link Vasiliy posted is really informative. You said it doesn't work for you ? Do you get any errors in your logs ?

0 votes
Ankita Sharma Jan 15, 2016

Thanos, the script worked fine but when used in post function, it did not create any issue sad. Rather, i got error as "groovyx.net.http.HttpResponseException: Bad Request".

Can you please let me know if i need to do something else also, in order to create issues in this way?

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Posted in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

670 views 7 0
Join discussion

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