Reputation: 347
This is the api look like. I want to write a jmeter script to upload a csv file. I tried by putting Content-Type: multipart/form-data in HTTP header manager. then added parameter appId, fileName and putted an csv file in Files Upload tab in JMeter. But my response is showing 400 - bad request.
@POST
@Path("/{cid}")
@Consumes({ MediaType.MULTIPART_FORM_DATA,
MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_JSON})
public Response uploadFile(
@Context UriInfo ui,
@PathParam("cid") String cid,
@QueryParam("appId") String appId,
@FormDataParam("file") InputStream inputStream,
@FormDataParam("file") FormDataContentDisposition fileDetail,
@FormDataParam("fileName") String fileName,
@Context SecurityContext securityContext) throws IOException {
// code goes here
}
Upvotes: 0
Views: 299
Reputation: 168217
Content-Type
header from the HTTP Header ManagerTick Use multipart/form-data
box in the HTTP Request sampler
In general the easiest way of generating proper HTTP Request sampler configuration for file uploading is just recording it using your favourite browser and JMeter's HTTP(S) Test Script Recorder. Just make sure that the file, you're uploading is present in JMeter's "bin" folder and JMeter should generate proper HTTP Request sampler so you won't have to do this manually. Check out Recording File Uploads with JMeter article for more information if needed.
Upvotes: 1