The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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!
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi everyone, We’re always looking at how to improve Confluence and customer feedback plays an important role in making sure we're investing in the areas that will bring the most value to the most c...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.