[英]REST API with MultipartFormDataInput returns 404 - Not Found
我在 TemplateResource 接口中有幾個 API,所有 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 的原因。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.