Angular Outlook REST API SendMail-的Http故障响应https://outlook.office.com/api/v2.0/me/sendmail: 401未经授权
我正在开发一个应用程序,它使用msgraph v.1.0生成的令牌通过outlook api v2.0发送电子邮件。它一直工作到几周前(据我所知),但自从上周三我尝试了它,它不工作(不发送电子邮件)!我以为这是我的代码,但我把它换成了我以前的代码,我仍然得到了这个错误: 我已经用邮件在Microsoft开发者网站上注册了我的应用程序。同时发送权限,并返回该网站确认。 我的应用程序也可以访问SharePoint,并且可以正常工作。。当我登录时,我打印我的令牌,它看起来很好。它以前发送过电子邮件。。我不知道发生了什么事Angular Outlook REST API SendMail-的Http故障响应https://outlook.office.com/api/v2.0/me/sendmail: 401未经授权,angular,typescript,nativescript,outlook-restapi,Angular,Typescript,Nativescript,Outlook Restapi,我正在开发一个应用程序,它使用msgraph v.1.0生成的令牌通过outlook api v2.0发送电子邮件。它一直工作到几周前(据我所知),但自从上周三我尝试了它,它不工作(不发送电子邮件)!我以为这是我的代码,但我把它换成了我以前的代码,我仍然得到了这个错误: 我已经用邮件在Microsoft开发者网站上注册了我的应用程序。同时发送权限,并返回该网站确认。 我的应用程序也可以访问SharePoint,并且可以正常工作。。当我登录时,我打印我的令牌,它看起来很好。它以前发送过电子邮件。。
"headers": {
"normalizedNames": {},
"lazyUpdate": null
},
"status": 401,
"statusText": "Unauthorized",
"url": "https://outlook.office.com/api/v2.0/me/sendmail",
"ok": false,
"name": "HttpErrorResponse",
"message": "Http failure response for https://outlook.office.com/api/v2.0/me/sendmail: 401 Unauthorized",
"error": null
}
我用来发送电子邮件的代码是:
private serverUrl =
"https://outlook.office.com/api/v2.0/me/sendmail";
constructor(private
http: HttpClient) {}
postData(data:
any, token:
any) {
let options =
this.createRequestOptions(token);
return this.http.post(this.serverUrl,
data, { headers:
options })
.map(res
=> res);
}
private createRequestOptions(token:
any) {
let headers =
new HttpHeaders({
"Authorization":
"Bearer " +
token,
"Content-Type":
"application/json"
});
return headers;
}
我正在传递这些值:
this.mailService
.postData(this.data,
this.token)
.subscribe(
() => {
dialogs.alert("Email sent. Thank you!").then(function () {
let page =
topmost().currentPage;
page.modal.closeModal();
});
},
(e) => {
console.log(e);
alert({
message: "An error occurred while sending your contact helpdesk.",
okButtonText:
"OK"
});
});
有人遇到过这个问题吗?我通过更改用于发送电子邮件的API解决了我的问题。我没有使用Outlook API,而是改为MSGRAPH,所以现在我的变量serverUrl是,现在可以工作了。我通过更改发送电子邮件的API解决了问题。我没有使用outlookapi,而是改为MSGRAPH,所以现在我的变量serverUrl是,现在可以工作了