{"record":{"id":"18f34a87e6b0fafc","repo":"cayleygraph/cayley","slug":"format-is-not-supported-for-reading-quads","errorCode":null,"errorMessage":"format is not supported for reading quads","messagePattern":"format is not supported for reading quads","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"server/http/api_v2.go","lineNumber":277,"sourceCode":"\t\treturn\n\t}\n\tw.Header().Set(hdrContentType, contentTypeJSON)\n\tresponse := newWriteResponse(n)\n\tencoder := json.NewEncoder(w)\n\tencoder.Encode(response)\n}\n\n// ServeDelete deletes data received in the request body from the database.\n// Responds with how many quads were deleted.\nfunc (api *APIv2) ServeDelete(w http.ResponseWriter, r *http.Request) {\n\tdefer r.Body.Close()\n\tif api.ro {\n\t\tjsonResponse(w, http.StatusForbidden, errors.New(\"database is read-only\"))\n\t\treturn\n\t}\n\tformat := getFormat(r, \"\", hdrContentType)\n\tif format == nil || format.Reader == nil {\n\t\tjsonResponse(w, http.StatusBadRequest, fmt.Errorf(\"format is not supported for reading quads\"))\n\t\treturn\n\t}\n\trd, err := readerFrom(r, hdrContentEncoding)\n\tif err != nil {\n\t\tjsonResponse(w, http.StatusBadRequest, err)\n\t\treturn\n\t}\n\tdefer rd.Close()\n\tqr := format.Reader(r.Body)\n\tdefer qr.Close()\n\th, err := api.handleForRequest(r)\n\tif err != nil {\n\t\tjsonResponse(w, http.StatusBadRequest, err)\n\t\treturn\n\t}\n\tqw := graph.NewRemover(h.QuadWriter)\n\tdefer qw.Close()\n\tn, err := quad.CopyBatch(qw, qr, api.batch)","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/server/http/api_v2.go#L259-L295","documentation":"The v2 HTTP DELETE data endpoint needs to parse a request body of quads. It picks a format from the Content-Type header via getFormat; if no format is negotiated or the format has no registered Reader, the endpoint rejects the request with 400. Only formats compiled in / registered (e.g. nquads) provide readers.","triggerScenarios":"Sending a DELETE request to /api/v2/data with an unsupported or missing Content-Type (e.g. application/json, text/plain), or omitting the Content-Type header entirely.","commonSituations":"API clients defaulting to JSON when posting quad deletion batches; servers built without a quad format registered; typos like application/nquads vs supported MIME strings.","solutions":["Set Content-Type to the supported quad MIME type (e.g. application/n-quads) on the DELETE request","Check which formats the server registered and use one with a Reader","Inspect the response body/format list (the formats endpoint) to find an acceptable Content-Type"],"exampleFix":"// before\ncurl -X DELETE -H 'Content-Type: application/json' --data-binary @quads.ndjson ...\n// after\ncurl -X DELETE -H 'Content-Type: application/n-quads' --data-binary @quads.nq ...","handlingStrategy":"validation","validationCode":"const ct = \"application/n-quads\"\nreq.Header.Set(\"Content-Type\", ct)\nif !strings.HasPrefix(req.Header.Get(\"Content-Type\"), \"application/\") {\n    return errors.New(\"DELETE data requires a quad Content-Type\")\n}","typeGuard":null,"tryCatchPattern":"resp, err := client.Do(req)\nif err != nil { return err }\nif resp.StatusCode == http.StatusBadRequest {\n    b, _ := io.ReadAll(resp.Body)\n    return fmt.Errorf(\"data delete rejected (check Content-Type): %s\", b)\n}","preventionTips":["Always send an explicit quad-format Content-Type on DELETE /data","Query the server's supported formats before integrating","Share one HTTP client wrapper that sets correct headers per endpoint"],"tags":["http","api","content-type"],"backgroundTag":"unsupported-operation","analyzedSha":"81dcd7d73e45136bc0d01802a8ba4685d8a533eb","analyzedAt":"2026-09-06T06:14:12.358Z","contentChangedAt":"2026-09-06T06:14:12.358Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}