Spring thymeleaf how call AP.request?

I am new to jira cloud development. I choosed spring-boot for backend. I have route in which I am rendering thymeleaf .html template. This is how it looks like.

<body>
Hi ${userName} !
</body>

<script src="https://connect-cdn.atl-paas.net/all.js"></script>

<script>
    AP.request({
        url: '/rest/api/latest/project',
        success: function(response) {
            // convert the string response to JSON
            response = JSON.parse(response);

            // dump out the response to the console
            console.log(response);
        },
        error: function() {
            console.log(arguments);
        }
    });
</script>

I imported all.js and tried call AP.request with no success.
Uncaught TypeError: AP.request is not a function
What am I doing wrong?

Hi @ladislavrolnik ,

Can you try moving the script inside the <body> (i.e. before the </body> tag).

Regards,
Dugald

1 Like

I have tried it after I uploaded app into cloud and worked.
Is not possible to test AP library on local spring-boot before
deployment?

Hi @ladislavrolnik,

all.js / AP is a bridge to the parent window of Jira that is including your app as an iframe. It can only be initialized when your app is being included as an iframe in Jira. So yes, you need to install your app in Jira Cloud if it requires the use of AP and you want to test it.

Cheers,
Sven

1 Like