Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

226
Views
Making an API call to Jenkins not working

Hi I am new to working with the Jenkins API, and I want to know why my current implementation is not working with the fetch API. I have tested its implementation with postman, and it works fine, however, when I use the fetch API in a node vue.js project, I getting a CORS error when I set the request mode to use cors, and a 403 forbidden error when I am using the no-cors mode. Here is my code that I currently have for my implementation:

fetch("https://<domain-url>/crumbIssuer/api/json",{
    method:'GET',
    mode: 'cors', //<=== cors request mode set here
    headers:{
        'Authorization': 'Basic <hashed username and password for jenkins basic authentication>',
        'Content-Type': 'application/json',
    },
}).then(res=>{
    if(res.ok){
        return res.json();
    }else{
        ....
    }
}).then(data=>{
    ....
}).catch(()=>{
    .....
});

If I use this code, I get a CORS error as shown in the following image: Jenkins CORS Error However, I do suspect that this can be fixed via the implementation of a proxy. Although, I would like to know if my fetch was just simply misconfigured in some way, such as the URL, headers, etc.

NOTE: I am using the exact same URL on my postman implementation: Setup in postman

Also, I tried setting the request mode to no-cors and got a 403 error: 403 error However, according to the article that I have linked below, setting the request mode to no-cors is not a good idea since it prevents front-end javascript code from reading the response body. Here is a link to that article:

Trying to use fetch and pass in mode: no-cors

I'm not sure why it returns a 403 forbidden error when in no-cors though.

I'm really thinking that a proxy server could solve this issue, but any other suggestions would be great. (Or pointing out a stupid mistake) thanks!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!