Raghu K
Raghu K

Reputation: 77

'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

Upvotes: 0

Views: 258

Answers (1)

lucas-nguyen-17
lucas-nguyen-17

Reputation: 5917

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")

Upvotes: 1

Related Questions