【发布时间】:2021-01-10 13:13:21
【问题描述】:
我正在开发一个离子应用程序,该应用程序对后端进行休息调用以发送电子邮件,当我进行休息通话时,我收到以下错误,可能是由于(邮递员中的休息通话有效,我使用 chrome禁用cors)
错误:
POST http://172.16.50.92/send 500 (Internal Server Error)
代码角度:
const params = {
'type': 'mail',
'attributes[to_recipients]': mail,
'attributes[body]': body,
'attributes[subject]': subject,
'attributes[attachments]': attachments
};
endpoint = url + '/send';
var headers_object = new HttpHeaders();
headers_object.append('contentType', 'application/json');
headers_object.append('Authorization', `Basic ${window.btoa(username + ':' + password)}`);
return this.http.post(endpoint, params, [headers_object]);
【问题讨论】:
-
尝试
Content-Type而不是contentType。相关doc. -
我已经尝试过这个解决方案,但我有同样的错误
标签: json angular rest ionic-framework ionic4