Search code examples
restpostmanbackendmultipartrest-assured

'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


I need to make a call to an endpoint using Restassured with a JPEG(Image file) file as multipart/form-data(content type). In the postman, the call is working fine, but its not the case when I execute through my code below. Any help would be much appreciatedenter image description here

Error: enter image description here


Solution

  • I think you just miss the mime-type for file upload.

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

    You just put image/jpeg for jpeg file.

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