public sealed class HttpBody : IMessage<HttpBody>, IEquatable<HttpBody>, IDeepCloneable<HttpBody>, IBufferMessage, IMessage
Message that represents an arbitrary HTTP body. It should only be used for
payload formats that can't be represented as JSON, such as raw binary or
an HTML page.
This message can be used both in streaming and non-streaming API methods in
the request as well as the response.
It can be used as a top-level request field, which is convenient if one
wants to extract parameters from either the URL or HTTP template into the
request fields and also want access to the raw HTTP body.
Example:
message GetResourceRequest {
// A unique request id.
string request_id = 1;
// The raw HTTP body is bound to this field.
google.api.HttpBody http_body = 2;
}
service ResourceService {
rpc GetResource(GetResourceRequest)
returns (google.api.HttpBody);
rpc UpdateResource(google.api.HttpBody)
returns (google.protobuf.Empty);
}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eHttpBody\u003c/code\u003e class represents an arbitrary HTTP body, designed for payload formats that are not JSON, like raw binary or HTML.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eHttpBody\u003c/code\u003e can be used in both streaming and non-streaming API methods, in the request and response, and as a top-level request field.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eHttpBody\u003c/code\u003e class contains properties for \u003ccode\u003eContentType\u003c/code\u003e, \u003ccode\u003eData\u003c/code\u003e as raw binary, and \u003ccode\u003eExtensions\u003c/code\u003e for application-specific metadata.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eHttpBody\u003c/code\u003e class provides methods for calculating the size, creating deep clones, merging messages, and writing data to a coded output stream.\u003c/p\u003e\n"],["\u003cp\u003eThe latest version available for \u003ccode\u003eHttpBody\u003c/code\u003e is version 2.15.0, but versions 2.10.0 and 2.2.0 are also available.\u003c/p\u003e\n"]]],[],null,["# Class HttpBody (2.17.0)\n\nVersion latestkeyboard_arrow_down\n\n- [2.17.0 (latest)](/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Api.HttpBody)\n- [2.15.0](/dotnet/docs/reference/Google.Api.CommonProtos/2.15.0/Google.Api.HttpBody)\n- [2.10.0](/dotnet/docs/reference/Google.Api.CommonProtos/2.10.0/Google.Api.HttpBody)\n- [2.2.0](/dotnet/docs/reference/Google.Api.CommonProtos/2.2.0/Google.Api.HttpBody) \n\n public sealed class HttpBody : IMessage\u003cHttpBody\u003e, IEquatable\u003cHttpBody\u003e, IDeepCloneable\u003cHttpBody\u003e, IBufferMessage, IMessage\n\nMessage that represents an arbitrary HTTP body. It should only be used for\npayload formats that can't be represented as JSON, such as raw binary or\nan HTML page.\n\nThis message can be used both in streaming and non-streaming API methods in\nthe request as well as the response.\n\nIt can be used as a top-level request field, which is convenient if one\nwants to extract parameters from either the URL or HTTP template into the\nrequest fields and also want access to the raw HTTP body.\n\nExample: \n\n message GetResourceRequest {\n // A unique request id.\n string request_id = 1;\n\n // The raw HTTP body is bound to this field.\n google.api.HttpBody http_body = 2;\n\n }\n\n service ResourceService {\n rpc GetResource(GetResourceRequest)\n returns (google.api.HttpBody);\n rpc UpdateResource(google.api.HttpBody)\n returns (google.protobuf.Empty);\n\n }\n\nExample with streaming methods: \n\n service CaldavService {\n rpc GetCalendar(stream google.api.HttpBody)\n returns (stream google.api.HttpBody);\n rpc UpdateCalendar(stream google.api.HttpBody)\n returns (stream google.api.HttpBody);\n\n }\n\nUse of this type only changes how the request and response bodies are\nhandled, all other features will continue to work unchanged. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e HttpBody \n\nImplements\n----------\n\n[IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage-1.html)[HttpBody](/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Api.HttpBody), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[HttpBody](/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Api.HttpBody), [IDeepCloneable](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1.html)[HttpBody](/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Api.HttpBody), [IBufferMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IBufferMessage.html), [IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage.html) \n\nInherited Members\n-----------------\n\n[object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)) \n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) \n[object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals)\n\nNamespace\n---------\n\n[Google.Api](/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Api)\n\nAssembly\n--------\n\nGoogle.Api.CommonProtos.dll\n\nConstructors\n------------\n\n### HttpBody()\n\n public HttpBody()\n\n### HttpBody(HttpBody)\n\n public HttpBody(HttpBody other)\n\nFields\n------\n\n### ContentTypeFieldNumber\n\n public const int ContentTypeFieldNumber = 1\n\nField number for the \"content_type\" field.\n\n### DataFieldNumber\n\n public const int DataFieldNumber = 2\n\nField number for the \"data\" field.\n\n### ExtensionsFieldNumber\n\n public const int ExtensionsFieldNumber = 3\n\nField number for the \"extensions\" field.\n\nProperties\n----------\n\n### ContentType\n\n public string ContentType { get; set; }\n\nThe HTTP Content-Type header value specifying the content type of the body.\n\n### Data\n\n public ByteString Data { get; set; }\n\nThe HTTP request/response body as raw binary.\n\n### Descriptor\n\n public static MessageDescriptor Descriptor { get; }\n\n### Extensions\n\n public RepeatedField\u003cAny\u003e Extensions { get; }\n\nApplication specific response metadata. Must be set in the first response\nfor streaming APIs.\n\n### Parser\n\n public static MessageParser\u003cHttpBody\u003e Parser { get; }\n\nMethods\n-------\n\n### CalculateSize()\n\n public int CalculateSize()\n\n### Clone()\n\n public HttpBody Clone()\n\n### Equals(HttpBody)\n\n public bool Equals(HttpBody other)\n\n### Equals(object)\n\n public override bool Equals(object other)\n\n**Overrides** \n[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object))\n\n### GetHashCode()\n\n public override int GetHashCode()\n\n**Overrides** \n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode)\n\n### MergeFrom(HttpBody)\n\n public void MergeFrom(HttpBody other)\n\n### MergeFrom(CodedInputStream)\n\n public void MergeFrom(CodedInputStream input)\n\n### ToString()\n\n public override string ToString()\n\n**Overrides** \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\n### WriteTo(CodedOutputStream)\n\n public void WriteTo(CodedOutputStream output)"]]