How to load json/js/other data resource from plugin with javascript?

I want to wrap my plugin into iframe (just like it works in jira cloud) so my code will not interfere with other plugins.
so i have JIRA 7.13 and something like this in atlassian-plugin.xml:

  <web-resource key="plugin-app-resources">
    <resource type="download" name="AP-Polyfill.js" location="/client/ap_polyfill/AP-Polyfill.js"/>
    <resource type="download" name="client/" location="/client/"/>
  <web-panel key="app-panel" location="atl.jira.view.issue.left.context" weight="50">
    <resource name="view" type="velocity" location="templates/panel.vm"/>

code inside templates/panel.vm:

<iframe id="uniqueId"></iframe>
<script type="text/javascript">
    //- init plugin
   iframe.src = 'bla-bla'
<!-- recommendations from this  -->
<!-- does not work -->
<!-- empty lines -->

so how can i load AP-Polyfill.js and other files inside iframe in runtime? WMR.require not available in iframe and it will load all data into parent window.
what i need is full url to AP-Polyfill.js. and i can get it from /jira/rest/webResources/1.0/resources rest point. but it’s private=(
is there any way to get this big url like /jira/s/d41d8cd98f00b204e9800998ecf8427e-CDN/-dfughe/713000/b6b48b2829824b869586ac216d119363/1.0.0/_/download/resources/plugin.jiraServerPlugin:plugin-app-resources/bla-bla.js with java (or js)?

1 Like


I suggest that You have to use the full path for Your web-resource and load it at the beginning of Your .vm-file:

    $webResourceManager.requireResource(<groupId>.<artifactId>:<web-resource key>)

Then You should be able to call the functions of Your AP-Polyfill.js.


i need to load files inside iframe. not outside=)
anyway i found solution with GET /rest/webResources/1.0/resources?r={pluginId}:jiraServerPlugin-app-resources
it’s private rest-point but it’s working.