Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular Outlook REST API SendMail-的Http故障响应https://outlook.office.com/api/v2.0/me/sendmail: 401未经授权_Angular_Typescript_Nativescript_Outlook Restapi - Fatal编程技术网

Angular Outlook REST API SendMail-的Http故障响应https://outlook.office.com/api/v2.0/me/sendmail: 401未经授权

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,并且可以正常工作。。当我登录时,我打印我的令牌,它看起来很好。它以前发送过电子邮件。。

我正在开发一个应用程序,它使用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是,现在可以工作了