{"record":{"id":"23397b59f8546d8e","repo":"influxdata/influxdb","slug":"unacceptable-content-type-expected-expected","errorCode":null,"errorMessage":"unacceptable content-type, expected: {expected}","messagePattern":"unacceptable content-type, expected: (.+?)","errorType":"http","errorClass":"Error::InvalidContentType","httpStatus":null,"severity":"error","filePath":"influxdb3_server/src/http.rs","lineNumber":216,"sourceCode":"\n    /// The request body content is not valid utf8.\n    #[error(\"body content is not valid utf8: {0}\")]\n    NonUtf8Body(Utf8Error),\n\n    /// The `Content-Encoding` header is invalid and cannot be read.\n    #[error(\"invalid content-encoding header: {0}\")]\n    NonUtf8ContentEncodingHeader(hyper::header::ToStrError),\n\n    /// The `Content-Type` header is invalid and cannot be read.\n    #[error(\"invalid content-type header: {0}\")]\n    NonUtf8ContentTypeHeader(hyper::header::ToStrError),\n\n    /// The specified `Content-Encoding` is not acceptable.\n    #[error(\"unacceptable content-encoding: {0}\")]\n    InvalidContentEncoding(String),\n\n    /// The specified `Content-Type` is not acceptable.\n    #[error(\"unacceptable content-type, expected: {expected}\")]\n    InvalidContentType { expected: mime::Mime },\n\n    /// The client disconnected.\n    #[error(\"client disconnected\")]\n    ClientHangup(Box<dyn std::error::Error + Send + Sync>),\n\n    /// The client sent a request body that exceeds the configured maximum.\n    #[error(\"max request size ({0} bytes) exceeded\")]\n    RequestSizeExceeded(usize),\n\n    /// Decoding a gzip-compressed stream of data failed.\n    #[error(\"error decoding gzip stream: {0}\")]\n    InvalidGzip(std::io::Error),\n\n    #[error(\"invalid mime type ({0})\")]\n    InvalidMimeType(String),\n\n    /// DatabaseName validation error.","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_server/src/http.rs#L198-L234","documentation":"`Error::InvalidContentType` is returned when the request's `Content-Type` is not acceptable for the endpoint; the error message includes the `expected` MIME type parsed into `mime::Mime`. Handlers require a specific media type (e.g. text/plain for line protocol) to parse the body correctly.","triggerScenarios":"POSTing line protocol without `Content-Type: text/plain` or application/xml variants the handler expects; sending JSON to a line-protocol endpoint or vice versa; missing Content-Type header entirely on strict handlers.","commonSituations":"Using the wrong endpoint for the payload format (v3 write_lp vs query JSON APIs), clients defaulting to application/x-www-form-urlencoded, or copying a curl example with an incorrect header.","solutions":["Set the Content-Type header to the expected value shown in the error message (e.g. text/plain for line protocol)","Match the endpoint to your payload format: JSON endpoints expect application/json, line protocol expects text/plain","Remove extra parameters from the Content-Type if they cause the mime parse/accept check to fail","Consult the endpoint docs in influxdb3_server for the accepted media types"],"exampleFix":"// before\ncurl -X POST http://localhost:8181/api/v3/write_lp?db=mydb -H 'Content-Type: application/json' --data-binary @metrics.lp\n// after\ncurl -X POST http://localhost:8181/api/v3/write_lp?db=mydb -H 'Content-Type: text/plain' --data-binary @metrics.lp","handlingStrategy":"validation","validationCode":"function matchesExpected(ct, expectedPrefix) { return typeof ct === 'string' && ct.startsWith(expectedPrefix); }\n// e.g. matchesExpected(headers['content-type'], 'text/plain') before calling write_lp","typeGuard":null,"tryCatchPattern":"try { await writeLP(lines); } catch (e) { if (String(e).includes('unacceptable content-type')) { headers.set('Content-Type','text/plain'); retry(); } else throw e; }","preventionTips":["Set Content-Type explicitly per endpoint (text/plain for line protocol, application/json for JSON APIs)","Read the expected type from the error message and align your header","Don't reuse one generic client config across JSON and line-protocol endpoints","Add integration tests asserting request headers"],"tags":["http","content-type","mime"],"backgroundTag":"invalid-argument-value","analyzedSha":"06200ef96ba82c5f6727e5038a83af8e722c6875","analyzedAt":"2026-09-19T12:55:30.003Z","contentChangedAt":"2026-09-19T12:55:30.003Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}