使用MultipartFormDataInput的REST API返回404 -未找到



我有几个api在TemplateResource接口,所有的api工作得很好,除了这个postFile。

@SecurityRequirement(name = "bearerAuth")
@Tag(name = "Template", description = "Operations related to Template")
public interface TemplateResource {
@POST
@Authorized
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Create a file.", responses = {
@ApiResponse(responseCode = "201", description = "File successfully created."),
@ApiResponse(responseCode = "400", description = "Invalid request provided."),
@ApiResponse(responseCode = "401", description = "Access token is missing or invalid."),
@ApiResponse(responseCode = "500", description = "An error occurred while processing request.", content = @Content(schema = @Schema(implementation = java.lang.Error.class)))
})
@Path("/amt/v1/generatedFile/task/{taskId}/secondarysource/{secId}")
Response postFile(
@Parameter(in = ParameterIn.PATH, description = "The task identifier.", required = true) @PathParam("taskId") Long taskId,
@Parameter(in = ParameterIn.PATH, description = "The secondary identifier.", required = true) @PathParam("secId") Long secId,
@RequestBody(
description = "A file sent using multipart/form-data",
required = true,
content = @Content(schema = @Schema(implementation = MultipartFormDataInput.class)))
MultipartFormDataInput input);
}
我有一个类来实现这个。为了调试,我试图返回一个值。
@Authorized
@Path("/")
public class TemplateEndpointImpl extends RestServiceBase
implements TemplateResource {
@Override
public Response postFile(Long taskId, Long secId, MultipartFormDataInput input) {
return Response.ok("Test").build();
}
}

当使用swagger时,我可以看到它已经打印出了这个API,但是当我尝试使用postman进行测试时,它返回404

知道是什么原因导致这个错误吗?如何解决这个问题?

感谢您的任何意见/建议。输入图片描述

输入图片描述

输入图片描述

输入图片描述

检查你的URL,在我看来,你在你的路径中缺少一些东西,这就是为什么你得到404 Not Found。

最新更新