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)
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
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.