Skip to content

NewtonsoftJsonContentSerializer.ToHttpContent(T) method

Defined in

Type: NewtonsoftJsonContentSerializer Namespace: Refit Assembly: Refit.Newtonsoft.Json.dll

Applies to

net10.0, net10.0-browserwasm1.0, net10.0-desktop1.0, net9.0, net9.0-browserwasm1.0, net9.0-desktop1.0, net8.0, net8.0-ios17.5, net8.0-maccatalyst17.5, net8.0-macos14.2, net8.0-macos14.5, net8.0-tvos17.2, netstandard2.1, net462, net481, net471

Attributes: [UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with RequiresUnreferencedCodeAttribute may break when trimming", Justification = "Interface method is unannotated on net8.0+ so cannot propagate; Newtonsoft path is documented as unsuitable for trimmed/AOT apps.")] [UnconditionalSuppressMessage("AOT", "IL3050:Calling members annotated with RequiresDynamicCodeAttribute may break when AOT compiling", Justification = "Interface method is unannotated on net8.0+ so cannot propagate; Newtonsoft path is documented as unsuitable for trimmed/AOT apps.")]

public HttpContent ToHttpContent<T>(T item)

View source

Inherited documentation

These docs were inherited from IHttpContentSerializer. The member doesn't override them on this type.

Summary: Serializes an object of type T to HttpContent.

Type parameters

NameDescription
TType of the object to serialize from.

Parameters

NameTypeDescription
itemTObject to serialize.

Returns: HttpContent -- HttpContent that contains the serialized T object.