Cloud REST call returns 403

Hi,

I am creating a cloud plugin. My REST call is:

$(document).ready(function() {
    $("#sampleForm").submit(function(event) {
      util.makeAjaxCall({
        contentEl: $("#msgDiv"),
        url : "/rest/agile/latest/board",
        type : "GET",
        contentType : "application/json",
        success : function(response) {
          document.getElementById("demo").innerHTML = JSON.stringify(response);
        },
      });
      event.preventDefault();
    });
  });
});

I get the following error:
response text: Forbidden (403) window.WRM=window.WRM||{};window.WRM._unparsedData=window.WRM._unparsedData||{};window.WRM._unparsedErrors=window.WRM._unparsedErrors||{}; WRM._unparsedData[“com.atlassian.plugins.atlassian-plugins-webresource-plugin:context-path.context-path”]=""""; WRM._unparsedData[“com.atlassian.plugins.atlassian-plugins-webresource-rest:curl.cross-origin-resources”]=“false”; WRM._unp…, status: 403, status text: error, url: /rest/agile/latest/board

Can someone help me understand what is going on?

UPDATE: When I call /rest/api it works. Jira Software REST call does not work.

Thanks heaps,
Justin

In order to make rest calls to JIRA from your addon’s page you must use AP.Request module of atlassian-connect. See this link for more info JS API

Thanks for the reply. AP.request is in utils.makeAjaxCall. Please see the update above.

In the console I am getting:
[Simple-XDM] Failed to validate origin
Do I need a credentials.json file or is there something wrong with authentication from my addon?
Like I said above /rest/api works. /rest/agile does not???

Are you including all.js from the host product in your html file?

Yes I am. The console stack trace looks like this:

If I click on the top batch.js link the following code is underlined:

apply(this,arguments)};if(b){window.fetch=function(j,m){var k=m||{};var l=k.headers;if(f.isHidden()){k.headers=(l)?new Headers(l):new Headers();k.headers.set(d,f.isHidden())}return b.call(this,j,k)}}a=true}},uninstall:function(){if(a){XMLHttpRequest.prototype.send=e;if(b){window.fetch=b}}a=false},addHost:function(j){i[j]=true}}});require("atlassian/analytics/user-activity-xhr-header").install();;

Hi, @ubangy. I was able to replicate the issue you encountered. Checking Jira Software REST Scopes, the {version} only accepts the value 1.0, not like the others that accept latest. In my test Jira cloud app where I replicated the issue, I changed “latest” to “1.0” and works as expected.

Hope this helps :slight_smile:
Ian

1 Like

This worked. Thanks so much.

You’re welcome :slight_smile: Kindly mark the solution so that the others who might be facing the same challenges can find the answer accordingly. Thanks!