get response using scriptrunner Rest API request takes too long

Jacob Gur-Arie October 31, 2019

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

0 votes
Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 31, 2019

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

Jacob Gur-Arie October 31, 2019

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]]]]
Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 1, 2019

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