我試圖在角度請求中轉換下面的示例代碼。Mailgun + AngularJS + Auhtentication爲http post請求
https://documentation.mailgun.com/user_manual.html#sending-via-api
curl -s --user 'api:YOUR_API_KEY' \
https://api.mailgun.net/v3/YOUR_DOMAIN_NAME/messages \
-F from='Excited User <[email protected]_DOMAIN_NAME>' \
-F [email protected]_DOMAIN_NAME \
-F [email protected] \
-F subject='Hello' \
-F text='Testing some Mailgun awesomness!'
我曾與仍回來了未經授權的錯誤授權頭下方嘗試。我看到請求頭具有設置值的授權字段。 我在做什麼錯?
var url = "https://api.mailgun.net/v3/sandboxXXXXXXXXXXXXXXXXX.mailgun.org/messages";
var dataFields = {
to: "verified recepient",
subject: "subject",
text: "text",
from: "postmaster address of sandbox domain"
}
var req = {
method : 'POST',
url: url,
headers : {
'Authorization' : 'Basic api:key-XXXXXXXXXXXXXXXX'
},
data: dataFields
}
$http(req).then(function(data){
console.log(data);
}, function(data){
console.log(data);
})
變種REQ = { 方法: 'POST', 網址:網址, 用戶名: 「API」 , 密碼:「API密鑰」, data:dataFields } –
不起作用仍然說禁止 – Sumant