unable to pass attachment and json together
Hi, i want to make a API automation using rest assured i am trying to sent a request where we have a file upload in body also it has some json string in body too how to add both at once please help to resolve this issue
public void Uploaddoc() throws IOException { File testuploadFile = new File("file path");
String payload ="content in jason";
RequestSpecification response = (RequestSpecification) given().
relaxedHTTPSValidation().
baseUri("url").port(port).
headers("Authorization", "Bearer "+getToken).
body("testuploadFile,payload").
when().
post("/path").
then().
log().all();
extract().response();
I checked two examples of file upload. I guess using .multipart method is the way to upload files.
https://github.com/rest-assured/rest-assured/blob/69576e40485c452be05a118a6b4271857d86fb21/examples/spring-mvc-webapp/src/test/java/io/restassured/examples/springmvc/controller/FileUploadUsingStandardRestAssuredITest.java#L40
Thank you @h3xh4wk , issue resolved by multipart method on file and json string in body with multipart