Using JavaScript API in my cloud plugin

Hi All,
I’m trying to create my first plugin for jira cloud :slight_smile:
I’m following this- Tutorial
but didn’t manage to understand how can I use the JavaScript API in my plugin
I keep getting - “AP is not defined” errors…
what am I missing? :thinking:


More than likely it’s that you’re missing the all.js which provides the AP object.


<script src="{{hostScriptUrl}}" type="text/javascript" data-options="sizeToParent: true;"></script>


<script src="" type="text/javascript" data-options="sizeToParent: true;"></script>

Hi @dar.kronenblum,

In addition to @danielwester’s response, you may like to follow the Jira Connect Getting started guide. That guide has a snippet that includes the all.js script tag plus the wrapping of your app content in a component with class="ac-content" so that your app’s iframe will be automatically sized according to your content if specified by the settings you provide such as data-options="sizeToParent: true;".


thanks @dmorrow, @danielwester
I did add the all.js tag to my code, but I’m still don’t manage to user the javascript api, for example to add flag as mention here, do you have an example of such use?

@danielwester I do think the {{hostScriptUrl}} is supported by ACE.
@dmorrow Did the status of {{hostScriptUrl}} change?

Hi @dar.kronenblum,

Can you share details about how you’re adding the script tag and when you see this error. For example, are you sure the script has been loaded before you attempt to access the AP global variable?


Depends on the version of ACE that they’re using. :slight_smile: It sounds like the script tag isn’t there though - thus hardcoding it isn’t that bad…

Hi @marc,

The {{hostScriptUrl}} code in the referenced tutorial is a remnant from when all.js had to be loaded from the tenant based location. When we introduced cacheable app iframes, we had to also introduce a way for apps to load all.js without being provided any context parameters, hence the fixed location. So the code in the tutorial implies it is configurable, but it should always be configured to the fixed location.


@danielwester @dmorrow Thanks for the clarification.
I thought it was best practice to use {{hostScriptUrl}} in case Atlassian might change the url of all.js.

Hi @marc ,
My advice would be to follow the “single point of maintenance” principle if possible. Whether that results in the URL being added to configuration is dependent on your app and probably just an implementation detail. Happy to hear other opinions though.