Atlassian SDK plugin sample code using Rest Module giving 404 when trying to execute rest call after deploying it on Jira On Prem

Can anyone suggest any solution? Same SDK plugin works fine when running using atlas-run command on local instance.

https://developer.atlassian.com/server/framework/atlassian-sdk/developing-a-rest-service-plugin/

It sounds like you’re encountering a common issue when deploying REST plugins on Jira On-Premises. Here are a few steps to troubleshoot and resolve the 404 error:

  1. Check URL Mapping: Ensure that the URL mapping in your atlassian-plugin.xml file is correct. The URL should follow the structure:
http://myhost.com:port/myapp/rest/api-name/api-version/resource-name

Verify that api-name, api-version, and resource-name are correctly defined.
2. Verify REST Servlet Configuration: Ensure that the REST servlet is correctly configured in your web.xml file. The REST servlet should be mapped to /rest.
3. Check Annotations: Make sure that your REST resource class is annotated properly with @Path and @Provider annotations.
4. Permissions: Ensure that the necessary permissions are set for the REST API endpoints2.
5. Plugin Activation: Verify that the plugin is activated and properly installed in Jira.
6. Logs: Check the Jira logs for any error messages that might give more insight into why the REST call is failing.

Your Jira On-Prem instance might have a different URL compared to the standard Jira development instance started with ‘atlas-run’ (localhost:2990/jira). Is the URL for your REST module generated automatically, or is it hardcoded?

To get the right Domain for the On Prem Instanse you can use this code example for your rest requests.

let baseUrl = AJS.Meta.get('base-url');
let restUrl = baseUrl + '/rest/pluginurl/1.0';

This will help you dynamically fetch the base URL. For example:

AJS.$.ajax({
        url: restUrl + '/health'
        type: 'GET',
        async: false,
        contentType: 'application/json',
        processData: false,
        success: function (response) {
           
        },
        error: function (response) {
        }
    });

Maybe it helps.

Best regards
Daniel