Forums

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

Can ScriptRunner support a pre-flight OPTIONS request?

mnd
Contributor
April 1, 2020

I'm trying to call a ScriptRunner method from a domain different than the one used with Jira. Using JavaScript I'm making a cross-domain request, and receiving the following error:

Access to XMLHttpRequest at '<<jira url>>' from origin '<<non-jira url>>' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

There is a ScriptRunner method that accepts GET methods, which is working fine, but this appears when trying to use a POST method.

I'm fairly certain I have all of the CORS pieces setup, except for allowing of the pre-flight OPTIONS request.

It seems that this won't work without the OPTIONS method being supported by the `httpMethod` parameter in the Groovy ScriptRunner script.

Any ideas how to get this to work?

3 answers

0 votes
Jamie Echlin _ScriptRunner - The Adaptavist Group_
Atlassian Partner
August 25, 2021

Is this a custom rest endpoint you are calling? 

Have you tried the method at https://jira.atlassian.com/browse/JRASERVER-65362 ?

Erez Marcovich
Contributor
August 25, 2021

Hi,

yes, it’s a rest endpoint that I’m calling

Erez Marcovich
Contributor
August 25, 2021

And yes, we did what mention in the ticket u mentioned. 
the issue is that when calling Jira oob post api it is working fine in Jira 8.13.7

bit when calling script runner rest endpoint it fails…

Jamie Echlin _ScriptRunner - The Adaptavist Group_
Atlassian Partner
August 25, 2021

Alright... to confirm, when you call one of the standard jira rest APIs with a POST, from another domain, it is working fine. But when you call a ScriptRunner rest endpoint, it is not.

The behaviour would be the same ideally. Please can you create a support request at https://productsupport.adaptavist.com/servicedesk/customer/portal/2 then we will reproduce and advise, or try to fix if it's something we are missing.

0 votes
Erez Marcovich
Contributor
August 17, 2021

@Jamie Echlin _ScriptRunner - The Adaptavist Group_ - hi jamie, 

can u response the above post?

thanks,

Erez

Erez Marcovich
Contributor
August 25, 2021

Hi, 

yes, it’s a rest endpoint that I’m calling 

0 votes
Erez Marcovich
Contributor
August 17, 2021

Hi,

anyone have an answer to the above question? i am facing same issue as well when trying to call script runner rest end point that do POST command.

when i call a jira OOB API it is working fine

 

thanks,

Erez

Suggest an answer

Log in or Sign up to answer