简体   繁体   中英

XSRF Check Failed on Jira Server

I am trying to call a POST (also tried a DELETE method) method of a Jira server rest api from an angular application. Unfortunately, I am getting 403 error and it's saying XSRF check failed

在此处输入图像描述

I tried adding X-Atlassian-Token: no-check but it does not do the trick for me. Also I tried replacing the header's value of 'User-agent' with a dummy one but I am getting

在此处输入图像描述

Here is the header

let headers = new HttpHeaders().set('content-type', 'application/json')
                               .set('X-Atlassian-Token','no-check')
                               .set('User-Agent','XX')
                               .append('Authorization', 'Basic ' + btoa(this.loginModel.username + ":" + this.loginModel.password));

I am getting completely frustrated because of this. Can anyone help me in this regard?

It is not possible to call protected APIs from third party websites as this would pose a security risk.

Atlassian

The solution that I found to this problem is that you need to add an origin header that matches the domain that you are sending the request to. For example, if you are using Postman to send a request to https://foobar.example/ then set the Origin header to https://foobar.example/ . then it should work. You can find some information about it here https://confluence.atlassian.com/kb/cross-site-request-forgery-csrf-protection-changes-in-atlassian-rest-779294918.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM