Я пытаюсь загрузить файл в приложение Angular7, но получаю ошибку ответа 400.
Тот же API работал для загрузки файлов в Angularjs, работает нормально.
Код AngularJS:
url: serviceUrl + '/docs/UploadFiles',
headers: {
Authorization: $scope.userData.token
},
data: {
file: capturedImagefile,
name: capturedImagefile.localURL,
refno: $scope.ticketLogData,
createby: $scope.userData.username,
dtype: 'Ticket-File',
companyid: $scope.userData.companyid
},
});
Код Angular7:
uploadPic(files: File) {
this.imageDetails = files[0];
console.log(this.imageDetails);
const data = {
file: this.imageDetails,
name: this.imageDetails.name,
refno: 123456,
createby: 'nayank',
dtype: 'Ticket-File',
companyid: 1010
};
this.httpclient.post(url, data) .subscribe(res => console.log(res));
ОШИБКА HttpErrorResponse {заголовки: HttpHeaders, статус: 400, статус-текст: «ОК», URL-адрес: «url ", ok: false,…}