Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to reduce the rest api url path in jira

Subhajit Bhuiya May 30, 2018

I was looking at the example https://developer.atlassian.com/server/framework/atlassian-sdk/developing-a-rest-service-plugin/ to create a Rest plugin for JIRA. To access the resource I have to give path like this

http://<host>:5990/refapp/rest/myrestresource/1.0/message

 

This seems to be too big path for me. We have to give the version number, which I do not want. I want something simple like this

 

http://<host>:5990/refapp/rest/myrestresource/message

 

How to do that with this example?

 

1 answer

0 votes
Higashi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 9, 2019

Simple answer: You cannot.

Longer answer is that the URL split into few parts, that are handled by different Atlassian product components:

Here's how the parts of the URL are composed and used:

http://host.com:port - The operating system directs the request to the application server (e.g. Tomcat) that handles the specified port.
/refapp - Tomcat directs the request to the application refapp.
/rest - The application's deployment descriptor file (web.xml) maps the URLs to the relevant servlets.

/api-name/api-version - The REST plugin module takes over. The relevant part of the URL (api-name and api-version) are defined as the path and version in the atlassian-plugin.xml file. For example:

<rest key="helloWorldRest" path="/myrestresource" version="1.0">
<description>Provides hello world services.</description>
</rest>

/resource-name - The final part of the URL mapping (resource-name and sub-elements) is done via annotations on the class, used to declare the URI path, the HTTP method and the media type.

If you'd like to have shorter URL, use single number version (ex. 1), and shorter path in your atlassian-plugin.xml file.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events