question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

equest failed with status code 403 XSRF check failed

See original GitHub issue

I have sucessfully opened a jira connection, I can read project version and now I like to add a new issue:

this.jira.issues.createIssue({
      'fields': {
        'project': {
          'key': 'testjira'
        },
        'summary': 'a single ticket',
        'description': 'a simple text',
        'issuetype': {'id': 1}
      }
    })
                    .then((currentIssue) => {
                      return currentIssue;
                    })
                    .catch((err) => {
                      this.logError(err);
                      this.handleError(err);
                    });

This creates an error: An error occured Error: Request failed with status code 403 XSRF check failed

A google search mentions that this is a problem of the User-Agent. I have tried to change it:

this.jira = new Client({
      host: host,
      baseRequestConfig: {
        headers: {
          'Content-Type': 'application/json',
          'User-Agent': 'dumy agent'
        }},
      authentication: {
        basic: {
          username: username,
          password: password
        }
      }
    });

However, this creates another error: Refused to set unsafe header “User-Agent”

Why can I read Jira, but cannot write to it?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
otto2mecommented, Mar 8, 2021

Awesome, it works now. Thanks alot for the support 😃

1reaction
MrRefactoringcommented, Mar 6, 2021

@otto2me

I found a workaround to unblock you with this problem. You need to add this piece of code to your main.js file for run electron:

electron.session.defaultSession.webRequest.onBeforeSendHeaders((details, callback) => {
  details.requestHeaders['User-Agent'] = 'SuperDuperAgent';
  callback({ cancel: false, requestHeaders: details.requestHeaders });
});

I will also attach these changes specifically in your application, I hope I did not leave sensitive data there 😂

SyncTool-Small.zip

I still haven’t figured out how to make it work in the browser. X-Atlassian-Token: nocheck will not work because this header can only be accepted on certain endpoints, createIssue is not included in this list.

Read more comments on GitHub >

github_iconTop Results From Across the Web

XSRF check failed when calling Cloud APIs
Atlassian Cloud REST API are protected from Cross Site Request Forgery (XSRF/CSRF) attacks for security reasons. For this reason, requests made ...
Read more >
XSRF check failed when sending POST to custom rest endpoint
Finally I solved the problem sending the request with AJAX and adding headers: { 'X-Atlassian-Token': 'nocheck' }. Hope this helps!
Read more >
XSRF Check Failed on Jira Server, Error 403 - NXP Community
I am trying to call a POST (also tried a DELETE) method of a Jira Server rest api from an angular application. Unfortunately,...
Read more >
Critical - Jira API call failing with 403 error · Issue #8091 - GitHub
... and RestAssured when I am trying to call same from Cypress it fails with 403 error - XSRF check failed var http...
Read more >
apache 2.2 - JIRA: XSRF check failed - Server Fault
It is highly possible that your proxy blocks some of headers. Try accessing jira directly (without proxy). Also, it is possible that JIRA's ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found