Search code examples
ajaxasp.net-web-apikeyauthorizationaccess-token

Rest API Using Authorization Key?


This is first time i have started working on Rest API's

I have tried a lot to find resources but couldnt achieve

as per documentation This has to be my request header and request will be POST

"Authorization": "125THIS123IS123TEST1354",
"cache-control": "no-cache",
"content-type": "application/json"

I have tried a lot to send data but got 401 Unauthorized error.

$.ajax({ 
   type: "POST",    
   url: 'https://testurl/api/test',    
   headers: {    
       'Authorization': '125THIS123IS123TEST1354',    
       'content-type': 'application/json',    
       'cache-control': 'no-cache'    
   },    
   success: function (data) {    
       alert('success')  
   },    
   failure: function (msg) {    
       alert(msg);    
   }    
});    

I don't know am going on right way or is their any other method.....


Solution

  • use

    'Authorization': 'Bearer 125THIS123IS123TEST1354',   
    

    For the source on the asp.net web API

    https://github.com/RemmSoft/rs-webapi2-advance-seed