Rest API使用授权密钥?

时间:2017-10-09 06:26:16

标签: ajax asp.net-web-api key authorization access-token

这是我第一次开始使用Rest API&#39>

我已经尝试了很多资源但却无法实现

根据文档这必须是我的请求标头,请求将是POST

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

我已经尝试了很多发送数据但却收到了401 Unauthorized错误。

$.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);    
   }    
});    

我不知道正确的方向还是他们的任何其他方法......

1 个答案:

答案 0 :(得分:0)

使用

'Authorization': 'Bearer 125THIS123IS123TEST1354',   

对于asp.net web API上的源

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