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

How to access XML search request from script? Edited

I am trying to create a script that needs to process an xml output from a JQL search request.

I am having issues just reading the url, and is very likely due to permissions, but can't seem to find a way to make it work.

I am trying a simple script to test:


String xml_url = 'http://jira.my-company.com:8080/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?jqlQuery=project+%3D+T500+AND+issuetype+%3D+Task'

return xml_url.toURL().text

but get a 400 error:

2018-01-23 17:25:36,400 WARN [common.UserScriptEndpoint]: Script console script failed: java.io.IOException: Server returned HTTP response code: 400 for URL: http://jira.my-company.com:8080/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?jqlQuery=project+%3D+T500+AND+issuetype+%3D+Task at Script360.run(Script360.groovy:5)

 

I have trying passing the &?os_authType=basic and even &?os_username=un&?os_password=pwd (which I agree is not a good idea), and still same error.

If I use a non authenticated url, i.e. 'http://www.google.com', it works.

Does anyone know a reasonable way to access and read XML output from a JQL request using scripts in JIRA? 

Thanks!

 

1 answer

It's more a question than an Answer, 

But is there a reason you want your search to return an XML.

When I use Script to do an Issue search, I usually prefer to get a collection of IssueObjects

This way you don't have to deal with an unofficial way to get your issues.

Like something like this : 

import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.web.bean.PagerFilter

public static List JqlSearch(String jqlString) {
try {
SearchService searchService = ComponentAccessor.getComponent(SearchService.class)
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
SearchService.ParseResult parseResult = searchService.parseQuery(user, jqlString)
if (parseResult.isValid()) {
def result = searchService.search(user, parseResult.getQuery(), PagerFilter.getUnlimitedFilter()).getIssues()
return result
} else {
return null
}
}
catch (Exception e) {
}
}

 

Another solution would be to go through the Real REST API, and then convert the JSON result into XML

Like in this example

https://stackoverflow.com/questions/29937254/convert-json-to-xml-using-groovy

Thanks for your input. 

To answer your question, I am using XSLT processing to create output from XML, so I did not want to necessarily add another step to go from JSON to XML. 

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

41 views 0 2
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