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 to get a simple return from Insight API call?

Currently when I use API call to get Insight objects, it returns lots of information besides the objects and attributes. I have to look up exactly what I need from the returns in order to do the rest of the work. The information returned from an API call is really overwhelming. Anyone has a good idea how to make the return data as simple as just return the value of the attribute?

Many thanks.  

3 answers

0 votes
Ravi Sagar Community Leader Apr 30, 2021

Hi @Wenping Li 

How are you using the API? From Jira automation rules or a ScriptRunner or any other tool. For retrieving the information by making a REST call you will get a JSON that you need to parse to get the information you are looking for. 

If you are using ScriptRunner then take a look at this page for some information and sample scripts to make a REST call.

For testing REST endpoints I use Talend API test extension or POSTMAN.

I hope it helps.

Ravi

Hi Raiv, thanks for the response. We use REST API call to get a JSON, then parse to get data that we need. The difficulty here is the data returned from the REST API call contains too many information, and it takes lots of effort to develop the parse process, especially there are many objects we will need to develop the parse process in java/phythen. We expected that the REST API call should just return the information for the attributes that are defined in the object. 

We will take a look the ScriptRunner page you provided. Thanks for that. We do use PSOTMAN to get API return too. 

 

Wenping

0 votes

I don't think the Insight REST API has an equivalent to the "fields" filter that the Jira Issue API offers to only include the attributes you can about.

https://insight-javadoc.riada.io/insight-javadoc-8.6/insight-rest/#

You must either call the /object/{id} to get all the objects details, call /object/{id}/attributes to get just a list of attributes, or once you have a specific attribute id (unique to the object) then you can call /objectattribute/{id}

Be generally, with most modern languages you should be able to ingest the json into a structured object and then just fetch the necessary information.

For example, in groovy:

def parsedJson = New JsonParser().parseText(jsonStringFromObjectApiResponse)
//get an attribute value:
def attribute = parsedJson.attributes.find{it.objectTypeAttribute.name='ABC Attribute'}
def attributeValue = attribute.ObjectAttributeValues[0].value //this assumes the attribute holds a single string value

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Staying organized with Jira: best practices for a better project management

Project managers know this problem: A “mountain of work” lays in front of you, and you don’t know how and where to tackle them. Different to-dos lie ahead, but just one task after the other can be ha...

237 views 2 1
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