Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

How can I get data from an external api, and fill out "new issue" fields with that data.

Hello,

I'm trying to do the following:

Create a new ticket in JIRA, and pull data from an external API, using that data to fill out the new JIRA issue fields.

 

This is because we use a separate helpdesk system, and our users need to pull those external helpdesk tickets and place them in JIRA to use them in their sprint.

 

The way I think I'd like it to work is to have a "helpdesk ticket ID" field in the new issue screen, and a button to "pull data now". That button would initiate a REST API call, passing in the helpdesk ticket ID as a parameter, and then place the details from the ticket into various fields, such as the description field.

 

I've been playing with scriptrunner to do this, and can't seem to figure it out. I have managed to make a test REST API call from the script console using this code I found:

 

private static get(String url) {
def connection = url.toURL().openConnection()
connection.addRequestProperty("Authorization", "Basic ${authString}")
 
connection.setRequestMethod("GET")
connection.doOutput = false
connection.connect()
connection.content.text

}

 

I can't figure out the following:

1. How to initiate this script based on a user clicking a button

2. How to do something with the data when it comes back.

 

 

Thanks for any help anyone can provide.

 

Dan

2 answers

Update: as I'm working through this, I've managed to get a scriptrunner groovy script to trigger based on clicking the Update button for an issue. I can get that to pull a value from a REST api call, and then display that output in a notification using the script below.

(The rest api call is just an easy example to prove I get data back)

 

Now I'm trying to figure out how I can SET the value of the "Description" field, with the output of my REST call.

 

Can anyone point me in the right direction for how to set the description field?

 

 

import com.onresolve.scriptrunner.runner.util.UserMessageUtil
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.customfields.option.LazyLoadedOption

    private static get(String url) {
        def connection = url.toURL().openConnection()
        connection.setRequestMethod("GET")
        connection.doOutput = false
        connection.connect()
        connection.content.text
    }


def output = get('https://api.macvendors.com/8c8590')


UserMessageUtil.success("Output:" + output)

Hi @Dan Conroy ...were you able to get this working? I am trying to accomplish a similar functionality. 

 

Thank you

+1, looking for exactly the same

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Service Management

JSM June Challenge #2: Share how your business teams became ITSM rockstars

For JSM June Challenge #2, share how your non-technical teams like HR, legal, marketing, finance, and beyond started using Jira Service Management! Tell us: Did they ask to start using it or...

266 views 7 7
Read article

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