File System Content
In following examples backend expects a file passed as multipart/form-data . File content is expected to be stored in file field. Backend responds with received file name and file description.To POST form data, you need to use the same http.post statement as you saw in previous examples. Second parameter should be http.formData instead of a map payload we used for JSON . def imagePath = testResourcePath("src/test/resources/image.png") http.post("/file-upload", http.formData(file: imagePath)) { fileName.should == 'image.png' } Use http.formFile to override file name that is being sent to the backend. def imagePath = testResourcePath("src/test/resources/image.png") http.post("/file-upload", http.formData(file: http.formFile('myFileName.png', imagePath))) { fileName.should == 'myFileName.png' } Multiple form fields can be specified like in the example below. def imagePath = testResourcePath("src/test/resources/image.png") http.post("/file-upload", http.formData(file: imagePath, fileDescription: 'new report')) { fileName.should == 'image.png' description.should == 'new report' }