Log behaviour script REST API calls

I have asked this question in Script Runner support, so I realley appreciate any help that somebody can gives me:

I have implemented a behaviour initialiser function script which makes a REST API call.

The behavoiur script is executed one, two, three or four times (this behavoiur was reported https://productsupport.adaptavist.com/servicedesk/customer/portal/2/SRJSUP-2729) and I want to log how many times the REST API is called, filtering calls for example with Chrome debug tool or with some protocol analyzer like Wireshark, but I don't know how to filter the API REST calls because are wrapped into the script.

The REST API call is made like this:

Map getInstallInfo(OkHttpClient httpClient) {
    String url = ''    String projectName = getIssueContext().getProjectObject().getName()

    RequestBody body = RequestBody.create(MediaType.parse("text/plain"), JsonOutput.toJson([Product: projectName, Client: null]))
    Response response
    try {
        Request request = new Request.Builder()

        response = httpClient.newCall(request).execute()
        return response.isSuccessful() ? [contentText: response.body().string()] : [errorText: "${response.code()} - ${response.message()}"]
    } catch (e) {
        return [errorText: "${e.class.canonicalName} - ${e.message}"]
    } finally {

 Therefore, I want to know how many times this URL ( is called.

I really appreciate yout help.

Thank you in advanve.


1 answer

0 votes


I think you can not see it in a browser because rest is executed on the server. Put the first line in you rest api call( before String url)  log.error("rest executed") and search for the number of these messages in atlassian-jira.log

Hello Alexey,

Thank you for your response. However, I'm thinking in log the request when JIRA makes it.

I mean, I've put a log, as you said, in the first line method and then I see it in the atalassian-jira.log. This approach is rigth and useful, but I'm trying to intercept the REST API call in the exact moment when it is called. Because of that, I'm thinking in an analyzer like Wireshark to intercept this call, but I don't know how to intercept it, because if a filter by IP is done, it doesn't appear. 

To clarify, the analyzer would be in JIRA server.




I do not work with Adaptivist and that is why I do not have access to the source code of Scriptrunner. But here is my understanding on how the behavour works in your case.

Scriptrunner loads its generic JavaScript on the creation, edit, browse and transition screens. This generic Javascript calls REST modules of ScriptRunner which can execute the code which you defined in the behavour and return the result to the generic JavaScript.  Generic Javascript works on the result and makes changes to UI according to the result. Your custom Rest Call is executed on the server that is why you can not see its executions in your browser. You can only see Rest calls which are produced by the generic Javascript to  Scriptrunner Rest Api. For example that woud be the call


Push F12 key in your browser, go to Network part and you will see this call. But from this call you will not understand if it calls your custom Rest Api or not. That is why you can just see executions of your custom Rest api in atlassian-jira.log

Thanks Alexey for your explanation ;)

I could see that {{/rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/runvalidator.json}} is called and the response  contains all information about custom fields (errorMsg, helpText, setValue, validity, readonly, fieldOptions an dfieldType). 

This clarifies me how the calls to Script Runner are made, so thank you ;)

But I still have the doubt about how to filter in the JIRA server the REST API call to the endpoint {{}}. Now, I've untderstood that the solution shuold be found in the server side, but as I mentioned before, if a filter by IP is done in JIRA server, no results are shown. So here is my doubt, why I can't see this filtered by IP results.

If you, or anyone, could figure out how to do, it would be great ;)


Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

1,101 views 4 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you