I have a plugin with the Java class A. This class retrieves some information via the Java API and i want to access this information via the URL. The problem is, I dont know what the URL is to call the Method.
@GET@Produces(MediaType.APPLICATION_XML)@Path("test")public Project getProjects() {..........return project;}
What is the URL that I have to type in to call this Method and get the xml? I am running this on the localhost.
In your atlassian-plugin.xml you should have an entry to register your rest resources :
<rest key="my-plugin-rest-resources" name="My Plugin Rest Resources" path="/my-plugin" version="1.0"> <package>my.confluence.plugin.rest</package></rest>
Notice the path and version parameters
Then when defining your resources as follow
@Path("/project")public class ProjectResource {@GET @Path("/all") public Response allProjects() { ... }}
You can access them at the following URL :
htt://localhost:8080/confluence/rest/my-plugin/1.0/project/all
The version parameter allows you to evolve your api by maintaining backwards compatibility
<rest key="my-plugin-rest-resources" name="My Plugin Rest Resources" path="/my-plugin" version="1.0"> <package>my.confluence.plugin.rest.v1</package></rest>
<rest key="my-plugin-rest-resources" name="My Plugin Rest Resources" path="/my-plugin" version="2.0"> <package>my.confluence.plugin.rest.v2</package></rest>
If you want to ensure you are always using the latest api version then modify the URL as follow :
htt://localhost:8080/confluence/rest/my-plugin/latest/project/all
I have used Confluence as an example, but this should be applicable to all products AFAIK
It looks like you're new here. Sign in or register to get started.