Is it possible to attach a file to a JIRA issue from the client's browser?

To authenticate, I tried using using:

xhr.open(“POST”, “https://ashwinatmts.atlassian.net/rest/auth/1/session”);

But I get:
XMLHttpRequest cannot load https://ashwinatmts.atlassian.net/rest/auth/1/session. Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:5551’ is therefore not allowed access. The response had HTTP status code 403.

Given this this response, I don’t know if this is even possible.

Any insight into this issue would be helpful.

Hi @ashwin.nirmul

JIRA Cloud doesn’t support CORS: [JRACLOUD-30371] Allow cross-domain requests for CORS - Create and track feature requests for Atlassian products.

Our Atlassian Connect framework provides a module for add-ons to make XHR requests in the browser without requiring CORS: https://developer.atlassian.com/static/connect/docs/latest/javascript/module-request.html

2 Likes

Thank you, Dave.

Is there an example of using ‘/rest/api/content/123456/child/attachment’ for JIRA?

I tried adding this code to the HelloWorld example (https://developer.atlassian.com/static/connect/docs/latest/tutorials/connect-basics.html), but I get error: [Simple-XDM] Failed to validate origin: https://ashwinatmts.atlassian.net.

Ashwin

Hi @ashwin.nirmul,

I believe the API path that you are referencing is for Confluence, not for JIRA.

There is a working (hopefully) example of using AP.request in a JIRA Cloud add-on if you run this demo app, which is based off of Atlassian Connect Express.