Error retrieving the macro body


I’m trying to retrieve the macro content from my macro (cloud) plugin with this piece of code:

private String getMacro(String url, String pageId, String pageVersion, String macroId) throws Exception {
    String path = "/rest/api/content/" + pageId + "/history/" + pageVersion + "/macro/id/" + macroId;      
    String result = atlassianHostRestClients.authenticatedAsAddon().getForObject(path, String.class);
    JSONObject json = new JSONObject(result);
    return json.getString("body");

RequestMapping(value = "/whatever", method = RequestMethod.GET)
    public String sequence(
            @RequestParam(name = "macroId") String macroId,
            @RequestParam(name = "pageId") String pageId,
            @RequestParam(name = "pageVersion") String pageVersion,
            @RequestParam(name = "xdm_e") String xdm,
            @RequestParam(name = "cp") String cp,
            Map<String, Object> model
    ) {
        String url = xdm + cp;
        model.put("url", url);
        String macroBody = getMacro(url, pageId, pageVersion, macroId);
        // ...

I’m using the atlassian-connect-spring-boot-starter framework.
When I try it in my Confluence testing installation (with development mode enabled), it works fine, but when I try from other Confluence Cloud installation it fails. It always returns 404, but 404 may mean “not found” or “invalid credentials”.

According to, the request should contain the JWT signed header, so no other steps should be required.

The scope I selected in the descriptor was just “READ”.

I’ve tried prepending it with the ur (i.e.: xdm_e + cp) and without it, and the result is the same: in my environment it works perfectly, but in the other one it fails.

Am I forgetting something or doing something wrong?

PD: it is a dynamic macro with url: “/whatever?macroId={}&pageId={}&pageVersion={page.version}”