We are moving our reporting tool from v2 to the v3 api using the documentation provided, but all attempts to perform a /rest/api/3/search/jql all result in an error response “{“errorMessages”:[“Invalid request payload. "]}. Refer to the REST API documentation and try again.”]}”. A snippet of my call is below.
func main() {
cloudId := "45exxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx10"
apiToken := b64.StdEncoding.EncodeToString([]byte("me@ctimeetingtech.com:XTYxxxxxxxxxxxxxxxxxxx71"))
url := fmt.Sprintf("https://api.atlassian.com/ex/jira/%s/rest/api/3/search/jql", cloudId)
method := "POST"
payload := strings.NewReader(`{
"expand": ["names","schema","operations"],
"fields": ["*all"],
"fieldsByKeys": false,
"jql": "status not in (Closed, Done) AND (reporter in membersOf(\"CTI Americas CS (AM)\") OR creator in membersOf(\"CTI Americas CS (AM)\") OR assignee in membersOf(\"CTI Americas CS (AM)\")) order by created desc",
"startAt": 0,
"maxResults": 1000
}`)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Accept", "application/json")
req.Header.Add("Authorization", fmt.Sprintf("Basic %s", apiToken))
req.Header.Add("Content-Type", "application/json")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
I have validated that the JQL executes cleanly and no updates are needed.
Do you have any thoughts and suggestions as to why my updated v3 search always fails, but when I execute the v2 previous call, it works fine and returns results as expected?