Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

AP is not defined

Deleted user March 7, 2017

In an Atlassian connect plugin, we've this code

$(document).ready(function() {
    AP.require('request', function(request) {

which works fine, but sometimes and randomly we receive the error message in the object

AP is not defined

And this is not related to a specific browser or OS

Any idea of why this happens?

Any suggestion on what to investigate?

Thanks

 

 

That's the head section of my web panel

<html lang="en">
    <head>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
        <script src="//aui-cdn.atlassian.com/aui-adg/6.0.6/js/aui.min.js"></script>
        <link rel="stylesheet" href="//aui-cdn.atlassian.com/aui-adg/6.0.6/css/aui.min.css" media="all">
        <link rel="stylesheet" href="mycustom.css">
        <script src="mycustom.js"></script>
    </head>

and that's the last part of the body

<!-- Stop the loading addon message -->
    <script id="connect-loader" data-options="sizeToParent:true;">
        (function() {
            var getUrlParam = function(param) {
                var codedParam = (new RegExp(param + '=([^&]*)')).exec(window.location.search)[1];
                return decodeURIComponent(codedParam);
            };

            var baseUrl = getUrlParam('xdm_e') + getUrlParam('cp');
            var options = document.getElementById('connect-loader').getAttribute('data-options');
            var script = document.createElement("script");
            script.src = baseUrl + '/atlassian-connect/all.js';

            if (options) {
                script.setAttribute('data-options', options);
            }

            document.getElementsByTagName("head")[0].appendChild(script);
        })();
    </script>
</body>

as described in the Atlassian dev documentation

3 answers

2 votes
Michael Eskin
Contributor
August 1, 2017

I am running into this exact same issue with loading all.js from our JIRA instance. The script loader is absolutely doing the right thing, we've used it forever for our Confluence add-on and I've verified that it's present and loaded in the DOM. It's all.js that has an issue when it tries to execute.

I'm getting an Uncaught TypeError: Object.defineProperty called on a non-object, and AP fails to be created or made available to our add-in

1 vote
Gajender Tyagi
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 14, 2021

Uncaught (in promise) TypeError: AP.request is not a function

I'm getting this error and don't know what's wrong, the only difference is I'm running the app in localhost.

1 vote
Volodymyr Krupach
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.
March 8, 2017

AP is defined in "integration bridge" all.js loaded from your host JIRA:

https://YOUR-ATLASSIAN-DOMAIN/atlassian-connect/all.js

I guess that all.js is not loaded (which should not happen) or maybe your load your custom JS file before all.js.

Deleted user March 8, 2017

all.js is loaded before my custom JS because the code works fine, 

and my JS is loaded at last in my web panel

but it seems that sometime (and I don't know when and why) 

AP is not available (i.e. all.js is not loaded?)

Like 2 people like this
Volodymyr Krupach
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.
March 8, 2017

Make sure you do no have async attribute in script tags.

Roma Bubyakin _Wombats Corp_
Contributor
March 4, 2019

Thanks @Volodymyr Krupach !

It was strange that AP works randomly, but removing async helped.

Like 2 people like this
Dang Thi Thuy Tien
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.
October 7, 2019

Hi @Volodymyr Krupach  ,

I try to add all.js to my plugin but I got this err: http://localhost:2990/jira/atlassian-connect/all.js net::ERR_ABORTED 404

 

It couldn't load

Do you have any idea about this?

Thanks

Volodymyr Krupach
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.
October 7, 2019 edited

Hi @Dang Thi Thuy Tien ,

Jira Cloud should NOT be loaded from localhost. You need to get development instance hosted by Atlassian. Here is a good tutorial: https://developer.atlassian.com/cloud/jira/platform/getting-started/

Dang Thi Thuy Tien
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.
October 7, 2019

Hi @Volodymyr Krupach 
Thank you so much, 

I find some link 

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

But  It has another error  :

AP.request({

Cannot read property 'request' of undefined

Thank you

Volodymyr Krupach
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.
October 7, 2019

all.js must be loaded from the hosting Jira. It's a bridge between hosting Jira and your app and it will not work when loaded from outside.

Like 3 people like this
Dang Thi Thuy Tien
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.
October 10, 2019

I got it, 
Thank you @Volodymyr Krupach  

Matti Kiviharju
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.
May 14, 2022

Can you post example how to define properly all.js into scritps? We have 401 authorization error...

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Upcoming Jira Events