AP.request 'Failed to validate origin' error

Hi,

I’m trying to use AP.request in my add-on to retrieve the projects list from the JIRA Cloud. Like this:

AP.request('/rest/api/2/project', {
  success: (response) => {
    const projects = JSON.parse(response);
    console.log(projects);
  },
  error: (response) => {
    console.log(arguments);
  },
  contentType: 'application/json',
});

unfortunately, I’m getting the “[Simple-XDM] Failed to validate origin” error. More specifically the console contains this:

GET https://mydomain.atlassian.net/rest/api/2/project?_=1500204531842 403 ()
[Simple-XDM] Failed to validate origin: https://mydomain.atlassian.net

If I visit the https://mydomain.atlassian.net/rest/api/2/project URL manually, I get the projects list without any problems.

Could someone please help with what could be the problem here?

Did you add the READ scope for your add-on? I believe that it is required even for READ operations.

2 Likes

It worked, thank you! I had to add the ‘read’ permission to the add-on descriptor:

  "scopes": [
    "read"
  ],