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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,555,354
Community Members
 
Community Events
184
Community Groups

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
Gonchik Tsymzhitov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Sep 08, 2018

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
AUG Leaders

Atlassian Community Events