获得UNAUTHORIZED ERROR 401 - Sendgrid API

时间:2018-05-03 14:59:52

标签: javascript angularjs sendgrid sendgrid-api-v3

我正在尝试通过其API在sendgrid列表上执行操作。 https://sendgrid.com/docs/API_Reference/Web_API_v3/Marketing_Campaigns/contactdb.html#List-All-Lists-GET

我正在使用它来设置我的代码,但是当我的Angular应用程序通过$ http执行请求时,我获得了错误401 UNAUTHORIZED。 我尝试在Python中提出相同的请求,但似乎工作正常。

var head = {'Authorization': 'Bearer SG.PE-XXXXXXXXXXXXXXXXXXXXXX'};
var sgUrl = "https://api.sendgrid.com/v3/contactdb/lists";

self.$http({
    method : "GET",
    url : sgUrl,
    headers : head,
}).then(function mySuccess(response) {
    alert(1);
}, function myError(response) {
    alert(0);
});

谢谢!

0 个答案:

没有答案
相关问题