Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

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

irina
irina 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.
Thanks,
Irina

Comments

  • Thomas Moore
    Thomas Moore Posts: 82 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!

    -Thomas

  • Ramiro Martinez
    Ramiro 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,

    Ramiro

  • OmarR
    OmarR Posts: 233 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.

    Steps:
    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.

    :neutral:

  • irina
    irina 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,
    Irina

  • irina
    irina Posts: 7