We are developing integration application between Jira SM and phone call system. We found out new “bug” what didn’t appear before. Here is our developers description of the issue:
It appears there is an issue with the AP.request call.
When I copy the request URL from the browser’s developer tools and run it directly in the browser, the ticket is returned correctly. However, the same request made through the AP.request library returns an empty list, and the ticket is not found.
I don’t understand why this is happening. The exact same HTTP GET request works when run directly in the browser but fails when using the AP.request library.
Here is the code for the request:
const response = await AP.request({
url: encodeURI(
“/rest/api/3/search?jql=” + query
),
type: “GET”,
experimental: true,
contentType: “application/json”,
});
Could community help to confirm is there a bug or what could cause this problem?
Hello @AleksiSalmela
Your question is tagged as related to JSM Development and you said you are connecting to ‘Jira SM’ (Service Management), but you have provided a URL for a Jira CLOUD REST API endpoint.
Either way, the endpoint /rest/api/3/search was deprecated months ago (refer to CHANGE-2046), so it’s unclear exactly how “exact same HTTP GET request works when run directly in the browser” as you claim.
Can you please provide a screen grab of a web browser session showing a successful GET request to that endpoint.
Hey,
We resolved this by changing the API endpoint. We now are using resource at /rest/api/3/search and pass the preferred jql as body param which seems to work for our use case (multiple custom field search parameters with OR clauses). Still using AP.request. This application is still on the Atlassian Connect, and will be migrated over to Forge sooner than later.
Actually, we are now using the latest API /search/jql documented here. https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-search/#api-rest-api-3-search-jql-get
Just pass the query to the request e.g.
`return new Promise((resolve, reject) => {
AP.request({
// The Jira REST API endpoint for searching
url: “rest/api/3/search/jql”,
// The type of request
type: 'GET',
data: {
jql: jqlQuery,
fields: 'key,summary,reporter,created,status,organizations',
maxResults: maxResults
},
// Callback function for a successful request
success: function (response) {
// The response is a string, so you need to parse it into a JSON object
const data = JSON.parse(response);
return (resolve(data.issues));
},
// Callback function for a failed request
error: function (xhr, statusText, errorThrown) {
console.error("Error executing JQL search.");
console.error("Status: " + statusText);
// The response from Jira often contains a useful error message
console.error("Response: " + xhr.responseText);
return reject({issues: []});
}
});
})`