Docs / SynthEvents / Errors / body-malformed

body-malformed

The body of the request is not a JSON object of the expected shape.

  • Status: 400 Bad Request
  • Routes: POST /api/v1/generate-events, QUERY /api/v1/read-data-set, QUERY /api/v1/read-domains
  • Description:
    • for generate-events: body is malformed: expected a JSON object with domain, scenario, range, eventCount, seed, and format
    • for read-data-set: body is malformed: expected a JSON object with name and format
    • for read-domains: body is malformed: expected an empty JSON object
  • Details: Empty, or field, the field to blame, by its path from the root of the body, such as eventTypePrefix or range.until.

Why It Happens#

  • The body is not JSON, or not a single JSON object, such as an array, null, or two objects in a row.
  • The body has a field that SynthEvents does not know. Field names are case-sensitive, so eventcount is unknown. A request names no event type prefix, so eventTypePrefix is unknown, too. If there are several unknown fields, field names one of them.
  • A value has the wrong type, such as eventCount given as the string "5000" rather than as a number, or range given as a string rather than as an object. field names it.
  • For read-data-set, the body has a field other than name and format, such as seed: a ready-made data set has its seed already.
  • For read-domains, the body has any field at all. It has to be exactly {}.

How to Fix It#

For generate-events, send a single JSON object with exactly the fields domain, scenario, range with from and to, eventCount, seed, and format, each of them with a value of its type (see API). For read-data-set, send a JSON object with exactly the fields name and format, both strings (see API). For read-domains, send {}.

Example#

For a request to generate-events with the field eventTypePrefix, SynthEvents answers:

{
  "type": "error",
  "data": {
    "code": "https://docs.synthevents.io/errors/body-malformed",
    "description": "body is malformed: expected a JSON object with domain, scenario, range, eventCount, seed, and format",
    "details": {
      "field": "eventTypePrefix"
    }
  }
}