【发布时间】:2020-08-22 06:27:39
【问题描述】:
我收到一个 HTTP 失败响应,我不明白为什么,因为 api 正在工作,我检查了 swagger/curl,它不是我的第一个服务,所有其他服务都工作正常
角度服务:
export class TicketPhotosService {
constructor(private http: HttpClient) { }
getTicketPhotos(iInstanceID: string): Observable<TicketPhoto[]> {
return this.http.get<TicketPhoto[]>(`${environment.url}api/v1/ViewTicketPhotos/GetPhotos`,
{ withCredentials: true, responseType: 'json',
params: {
iInstanceID
}})
.pipe(
catchError((err, caught) => {
throw ErrorResponseUtil.build(err);
})
);
}
控制器:
[Route("api/v1/[controller]")]
[ApiController]
public class ViewTicketPhotosConrtoller : BTSWebVCCAdminBaseController
{
IBALVccDefinitions _balVccDefinition;
private IHostingEnvironment _hostingEnvironment;
public ViewTicketPhotosConrtoller(IHttpContextAccessor contextAccessor, ISetting setting, ISecurity security, ILogging logging, IBal bal, IBalEmployee balEmployee, IBALVccDefinitions balVccDefinition, IWeb web, IDotNet dotNet, IDistributedCache distributedCache, ICache cache, IText text, IViewRender viewRenderService, IHostingEnvironment hostingEnvironment)
: base(contextAccessor, setting, security, logging, bal, balEmployee, web, dotNet, distributedCache, cache, text, viewRenderService, hostingEnvironment)
{
_balVccDefinition = balVccDefinition;
_hostingEnvironment = hostingEnvironment;
}
[HttpGet("GetPhotos")]
[BTSFilter(useMaintenanceFilter: true, useAuthentificationFilter: true, useCultureFilter: true, useLogAccessFilter: true, useSessionExpiredFilter: true, usePermissionApplicationFilter: false, usePermissionOptionFilter: true)]
[EnableCors]
public async Task<IActionResult> Get(string iInstanceID)
{
try
{
return Ok(GetImagePath(_balVccDefinition.GetImagesByQuestionnaireInstanceID(iInstanceID)));
}
catch (Exception ex)
{
var error = Logging.LogErrorWeb(ex, HttpContext);
return StatusCode(StatusCodes.Status500InternalServerError, new { error, message = "" });
}
}
【问题讨论】:
标签: angular http .net-core service http-status-code-404