I am consistently getting 404 response code when trying to query for an issue in Jira via Java/JQL/Jira API. The Urls below - when plugged in directly into the browser, i get correct results for both. Only via Java API do I get 404. I suspect something is wrong with the URI encoding but cannot figure it out.
Side note - the httpGet() works fine for every other Jira request I put together (Zapi, REST call, etcl), just not this particular one for whatever reason.
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URI;
import java.net.URL;
...
String urlStr = "https://jira.xxxx.com//jira/rest/api/2/issue/search?jql=project=XXXXX and summary ~ \"Testing Jira Integration Pass\"&fields=id,key,summary";
logger.debug("Url: " + urlStr.toString());
URL url = new URL(urlStr);
URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef());
url = uri.toURL();
logger.debug("Url Encoded: " + url.toString());
HttpURLConnection conn = httpGet(url.toString(), null, null);
logger.debug("Http Response Code: " + conn.getResponseCode());
Results:
2016-05-26 06:27:55 DEBUG - Url: https://jira.xxxx.com//jira/rest/api/2/issue/search?jql=project=XXXXX and summary ~ "Testing Jira Integration Pass"&fields=id,key,summary
2016-05-26 06:27:55 DEBUG - Url Encoded: https://jira.xxxx.com//jira/rest/api/2/issue/search?jql=project=XXXXX%20and%20summary%20~%20%22Testing%20Jira%20Integration%20Pass%22&fields=id,key,summary
2016-05-26 06:27:55 DEBUG - Http Response Code: 404