Using the Test Logger
The Logger tool helps with API call recording by facilitating complete captures of HTTP requests and responses (including the request and response bodies). Once this data is captured, it is sent to the API Testing Logger section for further inspections.
What You'll Need
- A Sauce Labs account (Log in or sign up for a free trial license).
- An existing API Testing Project. For details on how to create one, see API Testing Quickstart.
Running the Logger
Access Project
- Log in to Sauce Labs, then click API Testing.
- Go into a Project.
Create Webhook
- Create a webhook for your Project by clicking WebHooks > Create WebHook.
- Enter a Name (Description is optional), then click Save.
- Copy the Hook URL. Your Sauce Labs username, Sauce API Testing endpoint, and
{hook_id}
will populate automatically. For security reasons, you'll need to input your own Sauce Labs access key. Then, add/logger
to the end of the URL, so that it looks like this:https://{SAUCE_USERNAME}:{SAUCE_ACCESS_KEY}@{SAUCE_API_ENDPOINT}/{hook_id}/logger
Launch Piestry via CLI
-
From your CLI, launch Piestry, our API Mocking server tool, by running the following code. The last line will be the
--logger
switch, followed by the URL from the previous step:docker run --pull always -v "$(pwd)/myspec:/specs" \
-p 5000:5000 quay.io/saucelabs/piestry \
-u /specs/myspec.yaml \
--logger https://{SAUCE_USERNAME}:{SAUCE_ACCESS_KEY}@{SAUCE_API_ENDPOINT}/{hook_id}/logger -
In your CLI, make a call to any mocking endpoint (i.e.,
curl localhost:5000/api/v1/release-notes
).
Review Results
- From Sauce Labs API Testing, open the Logger section.
- Inspect the data related to the captured request (e.g., Request and Response).
- From here, you can see the call in the HTTP Client by clicking the Open button. Optionally, you can generate a test here by clicking the Generate Test button.
More Information
Coming Soon
The Logger is the first tool in an upcoming larger suite of API debugging tools.