HttpRequest Class

An HTTP request.

It should be passed to your client's send_request method.


>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest('GET', 'http://www.example.com')
<HttpRequest [GET], url: 'http://www.example.com'>
>>> response = client.send_request(request)
<HttpResponse: 200 OK>
Inheritance
azure.core.rest._helpers.HttpRequestBackcompatMixin
HttpRequest

Constructor

HttpRequest(method: str, url: str, *, params: Mapping[str, str | int | float | bool | None | Sequence[str | int | float | bool | None]] | None = None, headers: MutableMapping[str, str] | None = None, json: Any = None, content: str | bytes | Iterable[bytes] | AsyncIterable[bytes] | None = None, data: Dict[str, Any] | None = None, files: Mapping[str, str | bytes | IO[str] | IO[bytes] | Tuple[str | None, str | bytes | IO[str] | IO[bytes]] | Tuple[str | None, str | bytes | IO[str] | IO[bytes], str | None]] | Sequence[Tuple[str, str | bytes | IO[str] | IO[bytes] | Tuple[str | None, str | bytes | IO[str] | IO[bytes]] | Tuple[str | None, str | bytes | IO[str] | IO[bytes], str | None]]] | None = None, **kwargs: Any)

Parameters

Name Description
method
Required
str

HTTP method (GET, HEAD, etc.)

url
Required
str

The url for your request

Keyword-Only Parameters

Name Description
params
<xref:mapping>

Query parameters to be mapped into your URL. Your input should be a mapping of query name to query value(s).

headers
<xref:mapping>

HTTP headers you want in your request. Your input should be a mapping of header name to header value.

json
any

A JSON serializable object. We handle JSON-serialization for your object, so use this for more complicated data structures than data.

content
str or bytes or <xref:iterable>[bytes] or <xref:asynciterable>[bytes]

Content you want in your request body. Think of it as the kwarg you should input if your data doesn't fit into json, data, or files. Accepts a bytes type, or a generator that yields bytes.

data

Form data you want in your request body. Use for form-encoded data, i.e. HTML forms.

files
<xref:mapping>

Files you want to in your request body. Use for uploading files with multipart encoding. Your input should be a mapping of file name to file content. Use the data kwarg in addition if you want to include non-file data files as part of your request.

Variables

Name Description
url
str

The URL this request is against.

method
str

The method type of this request.

headers
<xref:mapping>

The HTTP headers you passed in to your request

content
any

The content passed in for the request

Attributes

content

Get's the request's content

Returns

Type Description
any

The request's content