Getting 404 error when retrieving JIRA ticket via REST API

I’m working with JIRA REST API for the first time and running into issues when trying to get ticket details from our server. I followed some online documentation but keep getting a 404 response.

public class TicketRetriever {
    public static void main(String[] args) throws URISyntaxException {
        final JerseyJiraRestClientFactory clientFactory = new JerseyJiraRestClientFactory();
        final URI serverUri = new URI("http://jira.mycompany.net:8080/jira/");
        final JiraRestClient jiraClient = clientFactory.createWithBasicHttpAuthentication(serverUri, "username", "password");
        final NullProgressMonitor monitor = new NullProgressMonitor();
        final Issue ticket = jiraClient.getIssueClient().getIssue("PRJ-789012", monitor);
        
        System.out.println(ticket);
    }
}

The error I get looks like this:

Exception in thread "main" com.atlassian.jira.rest.client.RestClientException: com.sun.jersey.api.client.UniformInterfaceException: Client response status: 404
    at com.atlassian.jira.rest.client.internal.jersey.AbstractJerseyRestClient.invoke(AbstractJerseyRestClient.java:70)
    at com.atlassian.jira.rest.client.internal.jersey.AbstractJerseyRestClient.getAndParse(AbstractJerseyRestClient.java:80)

I need to use VPN to connect to our JIRA server or else I get connection errors. Could this be a URL formatting issue or maybe I need different authentication? Any ideas what might cause this 404 response?

it might be a context path issue. some setups require /browse instead of /jira/. also, make sure PRJ-789012 is a valid ticket—just try pasting the URL in your browser and check what it shows.

Check if your JIRA instance uses a different context path. Some corporate setups have custom paths like /secure/ or /atlassian/jira/ instead of /jira/. That 404 means the endpoint isn’t found - not an auth issue. Test this by hitting http://jira.mycompany.net:8080/jira/rest/api/2/serverInfo first to confirm your base path works. If that’s fine, your issue key format might be wrong. Corporate JIRA instances sometimes use different project key patterns, or that ticket number doesn’t exist. Also check if your JIRA version supports the API you’re targeting - older instances might need /rest/api/1/ instead of /rest/api/2/.

That 404 error is likely your base URL or auth setup. Since you need VPN to reach the server, double-check that your serverUri points to the right JIRA instance. Try hitting http://jira.mycompany.net:8080/jira/rest/api/2/issue/PRJ-789012 directly in your browser to see if it’s even reachable. Also make sure your credentials have permissions for that specific project. I’ve run into this before where my account could access JIRA but was locked out of certain projects or issue types. One more thing - that NullProgressMonitor might be screwing things up. Try using a proper ProgressMonitor implementation instead.