Why does FusionAuth API return 406 Not Acceptable with gzip encoding?
-
When making API requests to FusionAuth with
Accept-Encoding: gziporAccept-Encoding: gzip, deflateheaders, the API returns a406 Not Acceptableerror instead of the expected response.However, when sending the same request with
Accept-Encoding: identity, the request succeeds and returns the expected data.What causes this issue and how should API clients handle content encoding when communicating with FusionAuth?
-
This behavior occurs when the client sends an
Accept-Encodingheader that includes compression algorithms, but FusionAuth's response handling doesn't support the requested encoding method in certain configurations.The solution is to explicitly use
Accept-Encoding: identityin your API requests. Theidentityvalue indicates that no encoding transformation should be applied, which FusionAuth handles correctly.If you're using an HTTP client library that automatically adds
Accept-Encoding: gzipor similar headers, you should:- Override the default
Accept-Encodingheader to useidentity - Or configure your HTTP client to not send compression-related headers automatically
Example:
GET /api/user/search HTTP/1.1 Host: your-fusionauth-instance.com Authorization: <your-api-key> Accept-Encoding: identityThis ensures consistent API responses without encountering 406 errors related to content encoding negotiation.
- Override the default
-
D dan has marked this topic as solved