Reference documentation and code samples for the Google API Common Protos Client class HttpBody.
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);
}
Example with streaming methods:
service CaldavService {
rpc GetCalendar(stream google.api.HttpBody)
returns (stream google.api.HttpBody);
rpc UpdateCalendar(stream google.api.HttpBody)
returns (stream google.api.HttpBody);
}
Use of this type only changes how the request and response bodies are
handled, all other features will continue to work unchanged.
Generated from protobuf messagegoogle.api.HttpBody
Namespace
Google \ Api
Methods
__construct
Constructor.
Parameters
Name
Description
data
array
Optional. Data for populating the Message object.
↳ content_type
string
The HTTP Content-Type header value specifying the content type of the body.
[[["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-09-04 UTC."],[],[],null,["# Google API Common Protos Client - Class HttpBody (4.12.3)\n\nVersion latestkeyboard_arrow_down\n\n- [4.12.3 (latest)](/php/docs/reference/common-protos/latest/Api.HttpBody)\n- [4.12.2](/php/docs/reference/common-protos/4.12.2/Api.HttpBody)\n- [4.11.0](/php/docs/reference/common-protos/4.11.0/Api.HttpBody)\n- [4.10.0](/php/docs/reference/common-protos/4.10.0/Api.HttpBody)\n- [4.9.0](/php/docs/reference/common-protos/4.9.0/Api.HttpBody)\n- [4.8.3](/php/docs/reference/common-protos/4.8.3/Api.HttpBody) \nReference documentation and code samples for the Google API Common Protos Client class HttpBody.\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.\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.\nExample:\nmessage GetResourceRequest {\n// A unique request id.\nstring request_id = 1;\n// The raw HTTP body is bound to this field.\ngoogle.api.HttpBody http_body = 2;\n}\nservice ResourceService {\nrpc GetResource(GetResourceRequest)\nreturns (google.api.HttpBody);\nrpc UpdateResource(google.api.HttpBody)\nreturns (google.protobuf.Empty);\n}\nExample with streaming methods:\nservice CaldavService {\nrpc GetCalendar(stream google.api.HttpBody)\nreturns (stream google.api.HttpBody);\nrpc UpdateCalendar(stream google.api.HttpBody)\nreturns (stream google.api.HttpBody);\n}\nUse of this type only changes how the request and response bodies are\nhandled, all other features will continue to work unchanged.\n\nGenerated from protobuf message `google.api.HttpBody`\n\nNamespace\n---------\n\nGoogle \\\\ Api\n\nMethods\n-------\n\n### __construct\n\nConstructor.\n\n### getContentType\n\nThe HTTP Content-Type header value specifying the content type of the body.\n\n### setContentType\n\nThe HTTP Content-Type header value specifying the content type of the body.\n\n### getData\n\nThe HTTP request/response body as raw binary.\n\n### setData\n\nThe HTTP request/response body as raw binary.\n\n### getExtensions\n\nApplication specific response metadata. Must be set in the first response\nfor streaming APIs.\n\n### setExtensions\n\nApplication specific response metadata. Must be set in the first response\nfor streaming APIs."]]