mirror of
https://github.com/interviewstreet/go-jira.git
synced 2025-06-18 23:57:32 +02:00
fix(issue): IssueService.Search() with a not empty JQL triggers 400 bad request (#292)
The JQL search term is escaped twice. closes issue #291
This commit is contained in:
42
examples/jql/main.go
Normal file
42
examples/jql/main.go
Normal file
@ -0,0 +1,42 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
jira "github.com/andygrunwald/go-jira"
|
||||
)
|
||||
|
||||
func main() {
|
||||
jiraClient, _ := jira.NewClient(nil, "https://issues.apache.org/jira/")
|
||||
|
||||
// Running JQL query
|
||||
|
||||
jql := "project = Mesos and type = Bug and Status NOT IN (Resolved)"
|
||||
fmt.Printf("Usecase: Running a JQL query '%s'\n", jql)
|
||||
issues, resp, err := jiraClient.Issue.Search(jql, nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
outputResponse(issues, resp)
|
||||
|
||||
fmt.Println("")
|
||||
fmt.Println("")
|
||||
|
||||
// Running an empty JQL query to get all tickets
|
||||
jql = ""
|
||||
fmt.Printf("Usecase: Running an empty JQL query to get all tickets\n")
|
||||
issues, resp, err = jiraClient.Issue.Search(jql, nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
outputResponse(issues, resp)
|
||||
}
|
||||
|
||||
func outputResponse(issues []jira.Issue, resp *jira.Response) {
|
||||
fmt.Printf("Call to %s\n", resp.Request.URL)
|
||||
fmt.Printf("Response Code: %d\n", resp.StatusCode)
|
||||
fmt.Println("==================================")
|
||||
for _, i := range issues {
|
||||
fmt.Printf("%s (%s/%s): %+v\n", i.Key, i.Fields.Type.Name, i.Fields.Priority.Name, i.Fields.Summary)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user