Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

jira issue key and RPC: request rejected (bad origin)

Srikanth Konjarla April 4, 2018

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.

3 answers

1 accepted

0 votes
Answer accepted
Srikanth Konjarla April 4, 2018

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}"
        }
    ]

0 votes
Mike Howells
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 24, 2018

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.

0 votes
Srikanth Konjarla April 4, 2018

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.

Suggest an answer

Log in or Sign up to answer