Hi,
I have created a small test app. It contains only one web_panel with a button. I would like to retrieve id of the current issue the panel is displayed within.
Here is my panel source:
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://unpkg.com/@atlaskit/css-reset@2.0.0/dist/bundle.css" media="all">
<script src="https://connect-cdn.atl-paas.net/all.js" async></script>
<!-- jQuery -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<!-- Atlassian User Interface (AUI) -->
<link rel="stylesheet" href="//aui-cdn.atlassian.com/aui-adg/5.7.0/css/aui.css" media="all">
<script src="//aui-cdn.atlassian.com/aui-adg/5.7.0/js/aui.js"></script>
<script>
function someTest () {
  console.log('Some test')
  AP.request({
    url: '/rest/api/latest/expression/eval',
    type: 'POST',
    headers: { 'Accept': 'application/json' },
    contentType: 'application/json',
    data: {
      expression: 'issue.key'
    },
    success: function (responseText) {
      console.log('Eval:', responseText)
    },
    error: function (responseText) {
      console.log('Eval error:', responseText)
    }
  })
}
</script>
</head>
<body>
  <section id="content" class="ac-content">
    <div>
      <button onclick="someTest()" target="_blank">Test</button>
    </div>
  </section>
</body>
</html>
But this does not work, the request returns this error:
Object { status: 400, statusText: “Bad Request”, responseText: “{"errorMessages":["Can not deserialize instance of com.atlassian.jira.rest.v2.expression.bean.JiraExpressionEvalRequestBean out of START_ARRAY token\n at [Source: com.atlassian.plugin.connect.plugin.auth.scope.InputConsumingHttpServletRequest$1@15fc521a; line: 1, column: 1]"]}”, getResponseHeader: getResponseHeader(), getAllResponseHeaders: getAllResponseHeaders() }
The only required body parameter is “expression” according to api-rest-api-2-expression-eval-post, so why it is complaining about the missing context, which BTW I am not able to provide from my panel.
Other requests works fine such as getting current user info:
AP.request({ url: '/rest/api/latest/myself', ... }) // works fine
Am I doing something wrong or is there any better approach to retrieve the current issue id?
Thank you