2
votes

Im using Symfony3 and i have this route:

/**
 * Recive a file
 *
 * @Route("/get/file", name="get-file")
 * @Method("POST")
 * @param Request $request
 * @return Response
 */
public function getFileAction (Request $request) {

    foreach($request->files as $key => $uploadedFile) {
        $name = "westSummary".date("Y-m-d")."_".$key.".csv";
        $file = $uploadedFile->move($destiny, $name); //Save the file in server, Where $destiny says.
    }

    return $this->json(array(
        'status' => 'success',
        'code' => 200,
        'data' => $request,
    ));
}

And i create a Collection in Postman calling this route and that return the JSON object correctly: responseBody

But i cant test if the CSV arrives to the request object. I have tryed this: csvtest

But the Response is the same in both cases

- How can i send a CSV to and API using POSTMAN?

1
What is the question? The method you posted has no connection to any CSV file posted - Nico Haase
at the end of the post are the questions. I need revice the file by post and i dont know how to do that - Oscar

1 Answers

3
votes

If you’re trying to do this via the collection runner, this functionality isn’t supported.

That collection runner option relates to the data file you want to use to populate the request variables and not a file upload.

This is a issue being recently discussed on the Postman GitHub account.

https://github.com/postmanlabs/postman-app-support/issues/3137

To upload a file in the request - You can do this by selecting the form-data option in the request body. There is a text/file dropdown - By selecting file you will get the option to choose one for the request.

File Upload

One other way that you can achieve this using a collection is by installing Newman and using this to create a script to upload the file during the test run.