Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Preflight CORS in JIRA REST API (GET request with headers) Edited

Hello,

I'm trying to use the REST API JIRA to catch informations about my installed plugins. To do that, I created an Angular 6 project and I used HttpClient to do an GET request wich I pass my basic authorization in the header.

 

I got an Preflight cors error..

app.component.ts

const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
'Authorization': 'Basic ' + btoa('xxx:xxx')
})
};
this.httpService.getHttp('https://jira.mydomain.com/rest/plugins/1.0/', httpOptions)
.subscribe(jsonPlugins => {
this.filterPlugins(jsonPlugins);
this.setPluginsLastestVersion();
});

http.service.ts

getHttp(url: string, httpOptions: {}) {
return this.http.get(url, httpOptions);
}  

I'm completly lost. If someone could help me

Have a good day, thanks

1 answer

 

Hi Julien,

As you are using angular js to access the plugin rest api installed in the jira, you are trying to make a Cross-origin HTTP request. In this case, the jira server has to allow the client (from where get request is made) to receive the response that it is sending.

So I guess, you need to add this header parameter 

Access-Control-Allow-Origin': '*'

in the response that you are sending from your plugin.

For more information regarding CORS, please check the following url

https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS

Also, I could find something similar in the atlassian community. Below is the link

https://community.atlassian.com/t5/Answers-Developer-Questions/Enable-CORS-in-JIRA-REST-API/qaq-p/553997

Hope this helps.

 

Thanks,

Santwana

Thanks for the response,

 

I'm not using Angular JS but Angular2 and I'm not working on a jira plugin but i'm trying to access informations about my installed plugins (https://jira.softcom.pro/rest/plugins/1.0/) from my website.

There is already in my HTTP request header.. That's why I don't understand where is the problem

'Access-Control-Allow-Origin': '*'

 Have a nice day

dur4791 I'm New Here Jul 05, 2021

Any updates on this issue? I'm facing the same issue.

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you