Rest Module Confluence Server Plugin

FROMAGE Nathan October 5, 2022

I've just create a Rest module plugin (from this documentation) for my Confluence plugin but when i try to make a js ajax call to my rest endpoint the request fail with no error and no statusCode. 

It is really possible to create a rest endpoint module for a confluence server plugin ?

1 answer

0 votes
aorlov October 6, 2022

Hi @FROMAGE Nathan 

Can you show your code?

FROMAGE Nathan October 10, 2022

Atlassian-plugin Code:

<rest name="Make Static Rest Resource"
i18n-name-key="make-static-rest-resource.name" key="nimp-pour-test"
path="/make-static" version="1.0">
<description key="make-static-rest-resource.description">Make Static Rest Resource Plugin</description>
</rest>

Rest Code:

@GET
@Produces({ MediaType.APPLICATION_JSON })
@Path("/makeStatic")
public Response MakeStatic(@QueryParam("pageId") String pageId) {
return Response.ok("test").build();
}

 Js Code:

$.ajax({
type : "GET",
url : window.location.origin + "/rest/make-static/1.0/makeStatic",
contentType : 'application/json'
}).always(function(msg) {
console.log("reponse de la requete" + msg)
if (msg == true) {
location.reload();
}
});
aorlov October 10, 2022

1. Your JS-code should provide query parameter `pageId`. You declared it in java code.

2. Have you annotation `@Path` on your controller?

3. You url in JS is wrong. Should be

Confluence.getContextPath() + 'rest/make-static/1.0/{controllerPath}/makeStatic?pageId=123'

 

Kind regards

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events