I have followed following "Getting Started" document to write cloud app to JIRA.
https://developer.atlassian.com/cloud/jira/platform/getting-started/
However, at the runtime it renders "Hello World" but it also has several "WARN" messages "RPC: request rejected (bad origin)". I have added following javascript snippet to the Hello World app to read the current jira issue key and I guess it is not working (returns null) due to the bad origin error but not sure.
var key = document.getElementById('key-val').getAttribute('data-issue-key');
I would like to know,
1. if "RPC: request rejected (bad origin)" is normal and can I start adding functionality?
2. What is the best way to obtain current jira issue from cloud app (Atlassian Connect JavaScript API)?
Thanks in advance.
I think I have solved my own question. I have passed the issue key via context parameter.
https://developer.atlassian.com/cloud/jira/platform/context-parameters/
Essentially, in atlassian-connect.json
"url": "/helloworld.html?issueKey={issue.key}"
Read it from helloworld.html
var issueKey = getUrlParam('issueKey');
Here is full listing of WebPanels
"webPanels": [
{
"key": "example-issue-left-panel",
"location": "atl.jira.view.issue.left.context",
"name": {
"value": "Example Left Panel"
},
"weight": 240,
"url": "/helloworld.html?issueKey={issue.key}"
}
]
You can get context parameters sent to your Add-on when the web panel loads, including the issue key. I'll try to get the docs updated to make this easier to discover.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Responding to my own question.
var key = document.getElementById('key-val').getAttribute('data-issue-key');
Above statement wouldn't work as "key-val" is not in the iframe.
var key = parent.document.getElementById('key-val').getAttribute('data-issue-key');
This statement would also does not work as iframe from another domain is not allowed to access parent's DOM from another domain.
Guess, I need a solution to get issue key using Atlassian Connect Javascript API or if there is a way to pass that information to iframe at the time of loading as a query parameter that would be nice.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.