ScriptRunner - How to form a get request inside Jira

Roberto L
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 21, 2017

Hello Community,

I have been looking for ways to construct a get request inside Jira.

I want to use the rest API inside a Behavior to fetch certain board related data: 

<jira Base URL>/rest/agile/1.0/board/{board Id}/configuration

Would anyone know how I can form a get request inside Jira as to receive a response from the url mentioned.

Thank you for your time and expertise!

-Roberto

 

 

1 answer

1 accepted

2 votes
Answer accepted
Daniel Yelamos [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 22, 2017

Hi Roberto.

I recently did an answer on how to use our HTTP request method from inside JIRA to make a request to any link. You can find relevant information in that question.

If you are still struggling. Could I ask you to give me an specific example of what it is that you want to accomplish? 

Cheers

Dyelamos

Roberto L
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 22, 2017

Hi @Daniel Yelamos [Adaptavist],

i read the attached community post.

i tried implementing the solution on my end but I got authorization errors.

i am trying to use a get request to get the information related to a board by passing the board Id to a REST API.

the API is: board/{boardID}/configuration

Do I need to pass my Jira credentials to the http request? If so how can I do so?

i appreciate your help!

-Roberto

Roberto L
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 26, 2017

Hi @Daniel Yelamos [Adaptavist]@Nic Brough -Adaptavist-

 

I have tried using the examples in the article you sent over in your last response but I have been getting this error: 

groovyx.net.http.HttpResponseException: Unauthorized

 I am doing the following in my code:

import groovyx.net.http.ContentType
import groovyx.net.http.RESTClient

def boardId = '3';
def activitiRestClient = new RESTClient("<Jira Base URL>/rest/agile/1.0/board/")
activitiRestClient.auth.basic "USERNAME", "PASWORD"

def response = activitiRestClient.get(
path: boardId+'/configuration'
)

output+="\nresponse: "+response+"\n"

Could you provide some pointers as to why this isn't working for me?

Thank you!!

-Roberto

Daniel Yelamos [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 20, 2017

Roberto. If you are getting that response it can mean one of two things:

1. Your request isn't well formed.

2. your username and password are not correct.

The best way you have of testing this would be to use a rest call plugin in firefox or similar, or the terminal if you are well versed and send the petition. Once and only once you get a proper response, compare the packages and see what the difference is. Then you will find why you are getting the auth error.

Cheers

Dyelamos

Roberto L
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 21, 2017

@Daniel Yelamos [Adaptavist],

Thank you, I forgot what I did but I ended up solving the issue.

-Roberto

Suggest an answer

Log in or Sign up to answer