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

get response using scriptrunner Rest API request takes too long

As part of migrating my system to the cloud I have to modify my script.
nn my server I used   the function issueManager.getIssueObject("MyIssueKey")

In the cloud I am forced to use   Rest request
example:

// Fetch the issue object from the key

def issue = get("/rest/api/2/issue/${issueKey}")

        .header('Content-Type', 'application/json')

        .asObject(Map)

        .body

When I rub this request for an issue the response time is 500ms and above
any way to speed it up ?

1 answer

Hi Jacob,

Thank you for your response.

I can confirm that the time it takes to return the results for your query depends on how long Atlassian take to return the data that is returned by your rest request. 

However, I can confirm if you only need some of the fields on the issue then you could look to only return the fields you need by specifying a queryStringParamater for just the fields that you require as described in the Rest API documentation page located here.

This would then reduce the amount of data that is returned and would help to speed up your request.

Finally, I can confirm that you can see more detailed information on the differences between the cloud and server versions inside of our documentation page located here.

If this response has answered your question can you please mark it as accepted so that other users can see it is correct when searching for similar answers.

Regards,

Kristian

Thank you Kristian for the prompt answer,

 

I have tried your suggestion using the following script:

import org.apache.log4j.Logger
import org.apache.log4j.Level

def log = Logger.getLogger("com.acme.CreateSubtask")
log.setLevel(Level.DEBUG)
//
import groovy.json.JsonSlurper
// log.setLevel(Level.DEBUG)

def issueKey = 'BUG-139051' //This is for test in a console

// Fetch the issue object from the key
def issue = get("/rest/api/2/issue/${issueKey}?fields=customfield_10036,customfield_10025")
.header('Content-Type', 'application/json')
.asObject(Map)
.body

log.debug issue
return issue

as you may see  the duration is still high 677ms

Serializing object into 'interface java.util.Map'
GET /rest/api/2/issue/BUG-139051?fields=customfield_10036,customfield_10025 asObject Request Duration: 677ms
[expand:renderedFields,names,schema,operations,editmeta,changelog,versionedRepresentations, id:89034, self:https://jira-xmpie.atlassian.net/rest/api/2/issue/89034, key:BUG-139051, fields:[customfield_10036:6428.0, customfield_10025:[self:https://jira-xmpie.atlassian.net/rest/api/2/customFieldOption/10103, value:uStore, id:10103, child:[self:https://jira-xmpie.atlassian.net/rest/api/2/customFieldOption/10106, value:uStore installers, id:10106]]]]

Hi Jacob,

Thank you for your response.

As mentioned previously the time that it takes to return the data is controlled by Atlassian and how long their systems take to respond to your request. 

I would advise contacting Atlassian direclty to ask them why the API is returning data slower than you expect. 

Regards,

Kristian

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira

The add-in you’ve been waiting for: Jira Cloud for Excel 🙌

Introducing Jira Cloud for Excel Here at the product integrations team at Atlassian, we are thrilled to announce the new Jira Cloud for Excel add-in! This add-in lets you export Jira data directly ...

881 views 7 24
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