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 Logger section in API Testing tool for further inspections.

What You'll Need#

Running the Logger#

Access Project#

  1. Log in to Sauce Labs, then click API TESTING > Get Started.
    API Testing landing page
  2. Go into a Project.

Create Webhook#

  1. Create a webhook for your Project by clicking Webhooks > Create hook
  2. Enter a Name for your webhook (Description is optional), then click Save.
    sample webhook details
  3. Copy the Hook URL and append it with /logger. Your Sauce Labs username, Sauce API Testing endpoint, and {hook_id} will populate automatically. For security reasons, you'll need to add your own access key.
    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 -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. See the data related to the captured request.
  3. Inspect the Request and Response.
  4. 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 UILogger UILogger UI

More Information#

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