Mohsin Arif

Mohsin Arif

  • 309
  • 6k
  • 138.5k

API show 400 Bad Request on Client Side

Nov 26 2019 12:14 AM
 
Hello all.
 
there is a api which is given to me for integration in my application. but i dont know what strtegy they has been followed when this made. only url and headers are given to me. 
when i integrate in my MVC project i have issue of Cross-Origin detail are in snapshot, i googled alot of time and as every one folllowed the strategy i modified my code but result is same. so please any one help me to fix this issue 
 code is below 
  1. <script>  
  2.     $(document).ready(function () {  
  3.         $('#btnLoad').click(function () {  
  4.   
  5.             $.ajax({  
  6.                 url: url,                  
  7.                 headers: {  
  8.                      'Access-Control-Allow-Origin': '*',
  9.                     "Authorization": "Bearer + token"  
  10.                 },  
  11.                 success: function (response) {  
  12.                     $.toaster({ priority: "success", title: "Congrat!", message: "Data loading...." });  
  13.                     console.log(response);  
  14.                 },  
  15.                 error: function () {                      
  16.                     $.toaster({ priority: "danger", title: "oooppss!", message: "failed" });  
  17.                 }  
  18.   
  19.             });  
  20.              
  21.         })  
  22.   
  23.     })  
  24.   
  25. script>  
 Error snpashot is attached 
thanksin advance  
more over when this api check by postman it fine. 
 
 
 

Answers (6)