Skip to main content

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

Running the Logger

Access Project

  1. Log in to Sauce Labs, then click API Testing.
  2. Go into a Project.

Create Webhook

  1. Create a webhook for your Project by clicking WebHooks > Create WebHook.
  2. Enter a Name (Description is optional), then click Save.
    sample webhook details
  3. 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

  1. 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
  2. In your CLI, make a call to any mocking endpoint (i.e., curl localhost:5000/api/v1/release-notes).

Review Results

  1. From Sauce Labs API Testing, open the Logger section.
    Logger UI
  2. Inspect the data related to the captured request (e.g., Request and Response).
  3. 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.
Logger UI Logger UI Logger UI

More Information

Coming Soon

The Logger is the first tool in an upcoming larger suite of API debugging tools.