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
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.