Create
cancel
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

REST API GROOVY "Not Found"

Hello,

I am trying to get pull requests information with this   
https://vulcan.stepstone.com/rest/dev-status/1.0/issue/detail?issueId=xxx&applicationType=stash&dataType=pullrequest where xxx is issue id :) and it works great but when i try to use it in my groovy code i get "Not Found" and don't know why :( can somebody help me with that?

import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.component.ComponentAccessor
import com.opensymphony.workflow.WorkflowContext
import com.atlassian.jira.workflow.WorkflowTransitionUtil;
import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl;
import com.atlassian.jira.util.JiraUtils;
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import groovyx.net.http.HTTPBuilder
import net.sf.json.JSONArray
import groovyx.net.*
import groovyx.net.http.*
import com.opensymphony.workflow.InvalidInputException
import groovyx.net.http.Method
import groovyx.net.http.RESTClient

//Managers

def issueManager = ComponentAccessor.getIssueManager()
def iLinkManager = ComponentAccessor.getComponent(IssueLinkManager)
def cfManager = ComponentAccessor.getComponent(CustomFieldManager)

def VULCAN_URL = "your jira adres"
def VULCAN_API_URL = VULCAN_URL + "rest/dev-status/1.0/issue/"
def jira = new HTTPBuilder(VULCAN_API_URL)
jira.setHeaders([Authorization: "Basic ${"login:password".bytes.encodeBase64().toString()}"])
def pullRequest
pullRequest = jira.get(path:'detail?issueId=406152&applicationType=stash&dataType=pullrequest')
return pullRequest



 

I get this error

 

groovyx.net.http.HttpResponseException: Not Found at groovyx.net.http.HTTPBuilder.defaultFailureHandler(HTTPBuilder.java:651) at groovyx.net.http.HTTPBuilder$1.handleResponse(HTTPBuilder.java:503) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:222) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:164) at groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:515) at groovyx.net.http.HTTPBuilder.get(HTTPBuilder.java:285) at groovyx.net.http.HTTPBuilder.get(HTTPBuilder.java:255) at groovyx.net.http.HTTPBuilder$get$0.call(Unknown Source) at Script354.run(Script354.groovy:33) 

1 answer

0 votes

Hi! 

Have you use for work with json these package

import groovy.json.JsonSlurper;
import groovy.json.StreamingJsonBuilder;

 And for connection do like this

def baseURL = VULCAN_API_URL;
URL url = new URL(baseURL);
URLConnection connection = url.openConnection();
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) }
connection.connect();

Hope you have been found solution also 

Cheers,

Gonchik Tsymzhitov

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Admins, notify your Jira instance of system-wide changes with the new admin announcement banner

Hi All! We’re excited to share the launch of an announcement banner that lets Jira site administrators communicate directly to their users across their  Jira Cloud instance.  ...

685 views 17 19
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