Я пытаюсь вызвать конечную точку веб-API asp.net из моего приложения angular 7, передав строковое значение и получив ошибку 404 not found.Если вы видите ниже, я вызываю getDocumentUploadDetailsByIds и передаю ему строку.Я преобразовываю целочисленный массив в строку и отправляю его
Вот как выглядит URL: http://localhost:56888/api/documentupload/detailsByIds/591006,591007
Компонент
public createDocument() {
const documents: IDocumentDetails[] = this.files.map(doc => {
return { // notice just a curly bracket, and in the same line with 'return'
file: doc.fileDropEntry.fileEntry,
documentTypeId: doc.selectedDocumentItem.Id,
name: doc.name,
documentDate: doc.selectedDate
};
});
this.documents = { managerStrategyId: 0, documentDetails: null };
this.documents.managerStrategyId = this.ManagerStrategyId;
this.documents.documentDetails = documents;
this.documentUploadService.createDocumentUpload(this.documents)
.then((result) => {
if (result) {
this.documentIds.ids = Object.keys(result).map(k => result[k]);
this.getDocumentUploadDetailsByIds(this.documentIds.ids.toString());
this.setGridOptions();
this.setColumns();
this.notify.success('Documents uploaded Successfully');
}
}).catch(err => {
this.notify.error('An Error Has Occured While uploading the documents');
});
}
public getDocumentUploadDetailsByIds(documentIds) {
if (this.ManagerStrategyId != null) {
this.Loading = true;
this.initGrid();
this.documentUploadService.getDocumentUploadDetailsByIds(documentIds)
.subscribe(data => {
this.DocumentUploadDetails = data;
this.Loading = false;
},
err => {
this.Error = 'An error has occurred. Please contact BSG';
},
() => {
});
}
}
Сервисный компонент
getDocumentUploadDetailsByIds(documentIds: string) {
return this.mgr360CommonService.httpGet('/api/documentupload/detailsByIds/' + documentIds );
}
httpGet(url: string): Observable<any> {
return this.httpClient.get( this.webApiLocation + url, httpPostOptions)
.pipe(map((response: Response) => {
return response;
}), catchError(error => {
this.onError(error);
return Promise.reject(error);
}));
}
Серверная часть
[HttpGet]
[SkipTokenAuthorization]
public IHttpActionResult DetailsByIds(string documentIds)
{
var viewModel = GetDocumentUploadDetailsByIds(documentIds);
return Ok(viewModel);
}