'has contents that are not what they are reported to be' - 尝试使用 RestAssured 上传 JPEG 文件(图像文件)时出现此错误

'has contents that are not what they are reported to be' - Getting this error when trying to upload a JPEG file (Image file) using RestAssured

我需要使用 Restassured 将 JPEG(图像文件)文件作为 multipart/form-data(内容类型)来调用端点。在邮递员中,调用工作正常,但当我执行下面的代码时情况并非如此。任何帮助将不胜感激

错误:

我想你只是错过了文件上传的 mime 类型。

RequestSpecBuilder addMultiPart(String controlName, File file, String mimeType)

你刚刚为 jpeg 文件输入 image/jpeg

addMultiPart("file", new File(FILE_TO_UPLOAD), "image/jpeg")