import

import expectations from a HAR or Postman collection, or re-import recorded traffic

Converts an HTTP Archive (HAR) export or a Postman collection into MockServer expectations and adds them. The format is auto-detected from the document structure or can be forced with the format query parameter.

With format=recording this instead re-imports a persisted NDJSON archive of recorded request/response pairs (one per line) back into the event log, so they become retrievable like in-memory recordings. That mode creates log entries rather than expectations.

put/mockserver/import

Request

  • Base URL: http://localhost:1080
  • URL: http://localhost:1080/mockserver/import
  • Auth: none declared

Query parameters

format'har' | 'postman' | 'recording'

forces the import format, supported values are "har", "postman" and "recording"; when omitted the format is auto-detected from the request body. "recording" selects the recorded-traffic NDJSON re-import rather than expectation import.

source'disk'

only used with format=recording. When "disk" - or whenever the request body is empty - the NDJSON archive is read from the path configured by persistedRecordedRequestsPath instead of from the request body; a missing archive file is a 400.

redactSensitiveDataboolean

redact sensitive headers and body fields from the imported document; enabled unless set to the literal "false"

additionalRedactedHeadersstring

comma-separated header names to redact in addition to the built-in set

additionalRedactedBodyFieldsstring

comma-separated body field names to redact in addition to the built-in set

consolidateboolean

when true, collapses imported exchanges that share a request shape (e.g. a HAR that captured the same endpoint many times) into a single reusable, unlimited-times expectation, sequencing any differing responses. Opt-in; default false imports verbatim, one expectation per exchange. Also implied by parameterize=true.

parameterizeboolean

when true, additionally generalises volatile path/query/header/body values in the consolidated expectations (implies consolidate). Opt-in; default false.

Request body

object required

a HAR export or Postman collection JSON document

Response

expectations created from the imported document

Expectation[] required(unresolved $ref)

list of upserted expectations

Changes

No recorded changes to this operation across all 1 revision of this API.