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

how can i return and parse json values in script console Edited

Hey guys, i want to create a issue on remote jira with jira  rest api. Codes in below, it's working great.  But i want to return json values, because when the issue created, json returns with issue id.  I need this id.




How can i get id. Can you help me please. Best regards.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.ComponentManager
import groovy.json.StreamingJsonBuilder
def baseURL = "full_url/rest/api/2/issue/";
def authString = "username:password".getBytes().encodeBase64().toString();
def body_req = [
           "fields": [
                "key": "TEKFENEHM"
            "summary": "REST API TEST example",
            "issuetype": [
                "name": "Question"
URL url = new URL(baseURL);
HttpURLConnection connection=(HttpURLConnection)url.openConnection();
connection.setRequestProperty( "Authorization", "Basic ${authString}" );
connection.requestMethod = "POST";
connection.doOutput = true;
connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
connection.outputStream.withWriter("UTF-8") { new StreamingJsonBuilder(it, body_req) }


1 answer

1 accepted

Hi Ali,


I'm having now the same issue. I would like to use the response of my POST, because i need the id too.


If you find the solution inform at this question, please!

I will be looking for the solution too.

Hey man, yes i found the solution.

I used the getInputStream method.

Here is the some documantations about this method.


and here is the my codes.

            InputStream response = connection.getInputStream();
            String response_string =response.getText()

            def jsonSlurper = new JsonSlurper()
            def json_object = jsonSlurper.parseText(response_string)
            assert json_object instanceof Map  

 If you have a problem please notify me. Regards.

Like # people like this


 I want to create an issue from Jira and get the issue details through the API. I need to receive the issue details, So that I can work with my third party app. Hope you can Understand my scenario. Please revert back if you have any solutions.


Suggest an answer

Log in or Sign up to answer

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