On making an API call to and endpoint in Golang I am passing CSV file as :
payload := &bytes.Buffer{}
writer := multipart.NewWriter(payload)
file, _ := os.Open("temp.csv")
defer file.Close()
part3,
errFile3 := writer.CreateFormFile("file", filepath.Base("temp.csv"))
_, errFile3 = io.Copy(part3, file)
if errFile3 != nil {
fmt.Println(errFile3)
return
}
_ = writer.Close()
req, _ := http.NewRequest("POST", url, payload)
req.Header.Set("Content-Type", writer.FormDataContentType())
But it is returning :
File with content-type application/octet-stream is not supported
But on making the same call from POSTMAN it is succeeding? Has anyone faced this?
Is there any way of passing content type as "text/csv" in Golang for file?