{"record":{"id":"9d6cc83ef857237c","repo":"reactiveui/refit","slug":"the-configured-ihttpcontentserializer-does-not-sup","errorCode":null,"errorMessage":"The configured IHttpContentSerializer does not support streaming responses. Implement IStreamingContentSerializer to return an IAsyncEnumerable<T>.","messagePattern":"The configured IHttpContentSerializer does not support streaming responses\\. Implement IStreamingContentSerializer to return an IAsyncEnumerable<T>\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Refit/RequestExecutionHelpers.cs","lineNumber":199,"sourceCode":"    /// <param name=\"cancellationToken\">A token to cancel streaming.</param>\n    /// <returns>An asynchronous sequence of deserialized elements.</returns>\n    /// <exception cref=\"NotSupportedException\">The serializer configured on <paramref name=\"settings\"/> does not implement <see cref=\"IStreamingContentSerializer\"/>.</exception>\n    [System.Diagnostics.CodeAnalysis.SuppressMessage(\n        \"Design\",\n        \"SST2307:Generic method type parameters should be inferable from the parameters\",\n        Justification = \"Type parameter intentionally specified explicitly by generated and reflection callers.\")]\n    internal static IAsyncEnumerable<T?> StreamResponseAsync<T>(\n        HttpClient client,\n        HttpRequestMessage request,\n        RefitSettings settings,\n        bool applyAuthorizationHeader,\n        int timeoutMilliseconds,\n        CancellationToken cancellationToken)\n    {\n        if (settings.ContentSerializer is not IStreamingContentSerializer streamingSerializer)\n        {\n            request.Dispose();\n            throw new NotSupportedException(\n                $\"The configured {nameof(IHttpContentSerializer)} does not support streaming responses. Implement {nameof(IStreamingContentSerializer)} to return an IAsyncEnumerable<T>.\");\n        }\n\n        var (token, timeoutSource) = CreateTimeoutToken(timeoutMilliseconds, cancellationToken);\n\n        return StreamResponseIteratorAsync<T>(\n            client,\n            request,\n            settings,\n            streamingSerializer,\n            applyAuthorizationHeader,\n            timeoutSource,\n            token);\n    }\n\n    /// <summary>Populates an empty Authorization header through the configured token getter, removing the header when the getter returns an empty token.</summary>\n    /// <param name=\"request\">The request to modify.</param>\n    /// <param name=\"settings\">The Refit settings to use.</param>","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/reactiveui/refit/blob/b455f65ecc4c97d092317e349cb775f9cfc6bcdf/src/Refit/RequestExecutionHelpers.cs#L181-L217","documentation":"StreamResponseAsync throws NotSupportedException when the configured IHttpContentSerializer does not also implement IStreamingContentSerializer. Streaming responses (IAsyncEnumerable<T>) require incremental deserialization, which the base content-serializer interface does not provide; the request is disposed before throwing.","triggerScenarios":"A generated or reflection interface method returns IAsyncEnumerable<T> and the RefitSettings.ContentSerializer is a serializer that only implements IHttpContentSerializer (e.g. a basic custom one) rather than IStreamingContentSerializer.","commonSituations":"Adding a streaming endpoint while using a custom serializer that lacks streaming support; using the default serializer in an older version before streaming was wired; substituting a Newtonsoft.Json-based serializer that does not implement the streaming interface.","solutions":["Use a content serializer that implements IStreamingContentSerializer (e.g. the System.Text.Json serializer with streaming support)","Implement IStreamingContentSerializer on your custom IHttpContentSerializer to provide incremental deserialization","Change the method return type away from IAsyncEnumerable<T> to a buffered type if streaming is not required","Register the streaming-capable serializer in RefitSettings before resolving the client"],"exampleFix":"// before\nvar settings = new RefitSettings(new MyBasicContentSerializer());\nvar api = RestService.For<IStreamApi>(host, settings);\nawait foreach (var item in api.StreamAsync()) { } // throws - no streaming support\n\n// after\nvar settings = new RefitSettings(new SystemTextJsonContentSerializer()); // implements IStreamingContentSerializer\nvar api = RestService.For<IStreamApi>(host, settings);\nawait foreach (var item in api.StreamAsync()) { }","handlingStrategy":"type-guard","validationCode":"if (settings.ContentSerializer is not IStreamingContentSerializer)\n    throw new NotSupportedException(\n        \"A streaming-capable serializer is required for IAsyncEnumerable<T> endpoints.\");\nvar api = RestService.For<IStreamApi>(host, settings);","typeGuard":"static bool SupportsStreaming(RefitSettings s) =>\n    s.ContentSerializer is IStreamingContentSerializer;","tryCatchPattern":"try { await foreach (var item in api.StreamAsync()) { /* ... */ } }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"streaming responses\"))\n{\n    // swap in an IStreamingContentSerializer or change the return type\n}","preventionTips":["Use a content serializer that implements IStreamingContentSerializer for streaming endpoints","Add a startup check that the serializer supports streaming when IAsyncEnumerable methods exist","Keep streaming and non-streaming serializers aligned to the same JSON stack","Write an integration test that consumes the first element of every IAsyncEnumerable method"],"tags":["streaming","content-serializer","iasyncenumerable","notsupported","configuration"],"backgroundTag":null,"analyzedSha":"b455f65ecc4c97d092317e349cb775f9cfc6bcdf","analyzedAt":"2026-08-13T21:20:57.878Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}