Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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 Marketplace Apps & Integrations

Staying organized with Jira: best practices for a better project management

Project managers know this problem: A “mountain of work” lays in front of you, and you don’t know how and where to tackle them. Different to-dos lie ahead, but just one task after the other can be ha...

229 views 2 1
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