Loop through files in a directory with POST http request for each file

irinairina Posts: 7

I have the following scenario I need to write automation with SOAtest:

I have an http POST request with an image in the body of that request and I have a directory with 1000+ files.

I need to run POST request with an image in the body for each file in that directory.

Please help.


  • Thomas MooreThomas Moore Posts: 77 admin

    Hi Irina,

    One easy way to do is this by using a File Datasource. You can point the File Datasource at any filepath on your machine, and it will add another row to each of its columns for every file in that directory.

    Once you have that configured, in your client with the POST request, switch it from text to File, and enter in ${File Path} to the Input File field.

    This will loop through your directory, sending every file specified in the Data Source.

    Let me know if this helps!


  • Ramiro MartinezRamiro Martinez Posts: 53 admin

    Hi Irina,

    I do not know which version of SOATest you are using, but have you taken a look at the file data source?
    The File data source allows you to select a directory and will set the file information within the directory as a rows in the data source.

    Using the File data source you can call the File Path that are stored in the File data source using ${File Path}.

    Best regards,


  • OmarROmarR Posts: 227 admin

    Hey Irina,

    To add to @Ramiro Martinez and @Thomas Moore lovely responses above, you can find a little more information on this tool in the SOAtest user guide located in your Installation directory. I attached the documentation here for your convenience.

    1) Create a FILE-Datasource to your Test suite.

    2) Configure your FILE-Datasource to point to your desired Directory hosting your +1000 files.

    3) Configure your Messaging Client to use the File-Datasource as the payload for your Requests. Please refer to the comments above for reference.


  • irinairina Posts: 7
    edited January 2017

    Thank you all for help. I got it to work. My POST body is slightly different from what you have in your example. Please see in the image below.

    Thanks again,

  • irinairina Posts: 7
Sign In or Register to comment.