Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

how to send file in request body rest assured

 public void sentFileInRequestBody() {

        //insert the file path you try to send in req body form-data
        File file = new File("");

        //base url 
        RestAssured.baseURI = "";
        
        RequestSpecification httpRequest = RestAssured.given()
                //insert query params
                .queryParam("key", "value")
                //insert headers
                .header("key", "value")

                //if you send files in request body -> form-data, use this
                .contentType("multipart/form-data")
                .multiPart("key", file);

        //Http request with base path
        Response response = httpRequest.request(Method.POST, "/your path");

        //print response
        String responseBody = response.getBody().asPrettyString();
        System.out.println(responseBody);
    }
Comment

PREVIOUS NEXT
Code Example
Java :: processing draw circle 
Java :: how to randomize an array java 
Java :: java how to get deltaTime 
Java :: javax.xml.bind does not exist 
Java :: fullscreen in java 
Java :: how can i to do java home 
Java :: java jtextfield text bold 
Java :: clear edittext android 
Java :: Recompile with -Xlint:deprecation 
Java :: android parse date 
Java :: java contains password input 
Java :: how to detenct free the end achievement spigot 
Java :: JFrame text java 
Java :: java get specific element from arraylist 
Java :: how to change a bukkit chat format 
Java :: sort array<entry float android studio 
Java :: java test if a string is a int 
Java :: how to write custom message for repeat password in joi 
Java :: java initialize map with values in one line 
Java :: Spring Boot Hibernate remove underscore naming strategy 
Java :: last method in jdbc 
Java :: spring data rest format time 
Java :: how to get date android studio 
Java :: list to observablelistz 
Java :: spring value # vs $ 
Java :: localdate to date java 
Java :: Convert Octal to Binary in java 
Java :: list extension quarkus 
Java :: spring enable cors 
Java :: string to long java 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =