You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+42Lines changed: 42 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@
5
5
The Batch Requests plugin for [Insomnia](https://insomnia.rest) adds the ability to send a request repeatedly, changing parts of every request by variable data, taken from a CSV file. For every response, some data can be collected and added to the CSV file.
6
6
7
7
- Repeatedly send a request by reading data from a CSV file
8
+
- Send files too by including their file path in the CSV file
8
9
- Extract data from JSON responses (or other sources, such as the response headers, status code and time taken) and write it back to the CSV file
9
10
- Works well if not using the plugin (when sending the request manually)
10
11
- Add a delay between each request
@@ -23,6 +24,9 @@ Go to the `Application>Preferences` menu in Insomnia, then go to the `Plugins` t
23
24
24
25
## Usage
25
26
27
+
> **Note**
28
+
> Want to send files in your repeated requests? See [below](#sending-files). The `Batch` tag that is described in this section sends text values only
29
+
26
30
The plugin adds a template tag to mark the places that you want to replace. To add it, press `Ctrl+Space`, search for the `Batch` tag and press `Enter`. Then, double click the tag to configure it. The tag can be inserted anywhere in the request (e.g. in the URL, query parameters, headers, or body)
27
31
28
32

@@ -55,6 +59,44 @@ On the plugin dialog, you should:
55
59
5. Click the `Run!` button at the bottom of the dialog. It will only become active when you have chosen a file and (if any outputs exist) completely filled all Outputs.
56
60
6. Click the `Save` button to write the extracted data back to the CSV file, if you need it. Wait until all requests have been performed (as indicated by the progress bar) before clicking this button.
57
61
62
+
### Sending files
63
+
64
+
Since `v1.5.0`, it's possible to also send _files_ that vary on each request, just like before it was possible to send _text_ that varied.
65
+
66
+
For example, this could be useful to upload several files at once to Google Drive: just prepare a CSV that lists the paths to the files and any other data that must vary per file (e.g. the file's title), and then run the request several times.
67
+
68
+
The CSV must look like this (it must contain a column, here called `fname`, that lists absolute file paths):
69
+
70
+

71
+
72
+
Then, create a request on Insomnia. Set its Body to Multipart. Add a new field to the body. Insert a `Batch (File)` template tag: place the cursor in the Value of the field, press `Ctrl+Space`, search for `Batch (File)`, and insert it:
73
+
74
+

75
+
76
+
> **Warning**
77
+
> Do _not_ change the field's type to File! Leave it as Text, which is the default. If you change it to File, it isn't possible to insert template tags, since Insomnia only shows the file picker button, so you'd be forced to choose one single file for all requests
78
+
79
+
Click on the newly-added tag to open its configuration dialog:
80
+
81
+

82
+
83
+
When configuring the tag, set the following two values:
84
+
85
+
- The name of the CSV column that will be replaced in this tag's location. Copy it from the first line of the CSV file, exactly (including capitalization)
86
+
- A sample value. This value will be used when sending the request manually. This is the value that you would have to edit manually if this plugin did not exist.
87
+
88
+
Click the Done button to save changes. The tag should now look like this:
89
+
90
+

91
+
92
+
From now on, the process continues as normal (see [the Usage section above](#usage)). Click the dropdown menu for the request, select the Batch Requests option, select a CSV file, configure any desired outputs, and click Run. Any fields whose content is a Batch (File) template tag will be replaced with the _contents_ of the file whose path is contained in the configured column of the CSV file. Requests will then be sent as normal. For example, this is the third request sent with the CSV file that was shown above:
93
+
94
+

95
+
96
+
If you send the request manually (e.g. by clicking the Run button, or by pressing `Ctrl+Enter` or `F5`), the file that will be sent will be the one that was configured on the template tag's **Sample Data** field:
97
+
98
+

99
+
58
100
### Sources of output data
59
101
60
102

0 commit comments