Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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

ScriptRunner - authentication inside REST endpoint


I'd like to create authentication inside my ScriptRunner Endpoint.

I've created a Script Runner REST endpoint that returns some data from my Jira instance and I'd like to access this data from other application (PowerBI)

The problem is that I am unable to configure authentication in my REST Endpoint.
Since I am able to pass from PowerBI application basic authentication parameters, I assume I should handle passed credentials in my Rest Endpoint function.

I 've reviewed some examples and tried to create authentication using code below, however it returns me an error "MissingMethodException"
Could you help me to understand what is wrong?


My code:

import org.apache.http.HttpRequestInterceptor;
import org.apache.http.HttpRequest;
import org.apache.http.protocol.HttpContext;
import groovy.json.JsonSlurper;
import groovy.json.JsonBuilder;
import static*
import groovy.transform.BaseScript

@BaseScript CustomEndpointDelegate delegate
AuthTest(httpMethod: "GET") { MultivaluedMap queryParams ->
    def JIRA_REST_URL = "https://<myJiraServer>"
    def JIRA_API_URL = JIRA_REST_URL + "/rest/auth/1/session"
    def http = new HTTPBuilder(JIRA_API_URL);
    def rt ='';
    def abc ='abcdefg one';
    http.request(Method.POST, ContentType.JSON) { resp, JSON ->
        //myname and mypass I will receive from PowerBi
        def body =  [username: 'myname', password: 'mypass']
            rt = JSON            
    //if request is OK, do something



2018-03-13 11:42:20,635 ERROR [common.UserCustomScriptEndpoint]: Script endpoint failed on method: GET AuthTest
groovy.lang.MissingMethodException: No signature of method: Script2013$_run_closure1$_closure2.doCall() is applicable for argument types: (org.apache.http.client.methods.HttpPost) values: [POST https://<myJiraServer>/rest/auth/1/session HTTP/1.1]
Possible solutions: doCall(java.lang.Object, java.lang.Object), findAll(), findAll(), isCase(java.lang.Object), isCase(java.lang.Object)    


Thank you in advance!






0 answers

Suggest an answer

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

🏊‍♀️ Atlympic Event: Trello

Hello Community!  Quick disclaimer: We are running a contest on Community (The Atlympics!) from July 23rd - August 8th of 2021. If you are interested in participating in this contest (prizes! ...

71 views 0 6
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