Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
At a glance
Goal: Create an HTTP file from intercepted API requests for reuse
Time: 10 minutes
Plugins: HttpFileGeneratorPlugin
Prerequisites: Set up Dev Proxy
Dev Proxy allows you to generate an HTTP file from intercepted API requests and responses. Using HTTP files is especially useful for developers who want to simulate API behavior or share reproducible API interactions. The HTTP file includes all relevant request and response details, with sensitive information replaced by variables for security and reusability.
To generate an HTTP file using Dev Proxy:
In the configuration file, enable the
HttpFileGeneratorPlugin:File: devproxyrc.json
{ "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v2.0.0/rc.schema.json", "plugins": [ { "name": "HttpFileGeneratorPlugin", "enabled": true, "pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll", "configSection": "httpFileGeneratorPlugin" } ], "urlsToWatch": [ "https://api.example.com/*" ], "httpFileGeneratorPlugin": { "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v2.0.0/httpfilegeneratorplugin.schema.json", "includeOptionsRequests": false } }Optionally, configure the plugin by adding the
includeOptionsRequestsproperty to thehttpFileGeneratorPluginsection. This property determines whether to includeOPTIONSrequests in the generated HTTP file. Default isfalse.In the configuration file, to the list of URLs to watch, add the URL of the API for which you want to generate an HTTP file.
The complete configuration file looks like this.
File: devproxyrc.json
{ "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v2.0.0/rc.schema.json", "plugins": [ { "name": "HttpFileGeneratorPlugin", "enabled": true, "pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll", "configSection": "httpFileGeneratorPlugin" } ], "urlsToWatch": [ "https://api.example.com/*" ], "httpFileGeneratorPlugin": { "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v2.0.0/httpfilegeneratorplugin.schema.json", "includeOptionsRequests": false } }Start Dev Proxy:
devproxyStart recording requests by pressing
r.Perform the API requests you want to include in the HTTP file.
Stop recording by pressing
s.Dev Proxy generates an HTTP file and saves it in the current directory. The file includes all captured requests and responses, with sensitive data like bearer tokens and API keys replaced by variables. For example:
@jsonplaceholder_typicode_com_api_key = api-key ### # @name getPosts GET https://jsonplaceholder.typicode.com/posts?api-key={{jsonplaceholder_typicode_com_api_key}} Host: jsonplaceholder.typicode.com User-Agent: curl/8.6.0 Accept: */* Via: 1.1 dev-proxy/0.29.0The plugin automatically creates variables for each combination of hostname and sensitive parameter, reusing them across requests when applicable.
Next steps
Learn more about the HttpFileGeneratorPlugin.
See also
- HttpFileGeneratorPlugin - Full reference
- Record and export proxy activity - Recording workflow
- Glossary - Dev Proxy terminology