I am trying to write a method that will respond to this http request. Unfortunately, I do not know what the argument of such a method should be.
cat data.csv | curl --header "Content-Type: text/plain" --request PUT --data-binary @- http://localhost:8080/endpoint
Swagger :
put:
tags:
- "employees"
summary: "Stores employees hierarchy tree on server"
description: "Sends or replaces employees hierarchy tree on server"
operationId: "endpoint"
consumes:
- "text/plain"
parameters:
- in: "body"
name: "body"
description: "CSV with four columns - employee id, employee name, employee surname and employee superior id. Columns are separated with ',' character."
required: true
schema:
type: string
example:[tons of employees data here]
At first I thought it would be a Multipartfile and then I would just process it (see dummy approach below), but then I saw a "string" in swagger and it confused me a bit. I have no clue anymore what the format of the input data is.
@PutMapping("/endpoint")
public void readCSV(MultipartFile file) throws IOException {
String content = new String(file.getBytes());
System.out.println(content);
}