Capture cURL requests
There are three options for importing cURL requests into API Studio.
- Importing a single cURL request: See here
- Capturing cURL requests from scripts: Covered in this article.
- Importing collections: See here
Steps to capture cURL requests from script
You can capture cURL requests issued by a script on your local machine by sending the cURL request to the target API via the API Studio proxy. You will need to make a change to cURL request in order for it to be captured via the proxy.
- Point the request to the API Studio proxy running at http://localhost:9000 (or the port where you configured the proxy to run).
- Change the path of the API calls to add the service name to the path in the format servicename/API-path.
- Configure API Studio to forward the request to the actual service.
- Select the collection to store the captured cURL requests in.
Original cURL request:
In order to forward the request to the destination via the API Studio proxy, you need to make the following changes.
- In the API Editor, set up a proxy configuration for the url(s).
- Click the Proxy settings button.
- In the Service configurations tab, create a configuration with a service name moviebook for the url https://moviebook.meshdynamics.io. Save the configuration.
- Select the proxy configuration from dropdown.
- Select the collection where the captured requests will be stored.
- Click the Proxy Settings button.
- Click the Mock Settings tab, and select the destination collection from the Save to collection dropdown.
- In your script, change the request to send it to the localhost:9000 (or the port where you configured the proxy to run). Add the service name configured in the previous step as the first path parameter.
Now if you run the script, the cURL requests above will be automatically captured by API Studio.