Table of Contents

Interface IAPIResponse

Namespace
Microsoft.Playwright
Assembly
Microsoft.Playwright.dll

IAPIResponse class represents responses returned by GetAsync(string, APIRequestContextOptions?) and similar methods.

public interface IAPIResponse : IAsyncDisposable

Properties

Headers

An object with all the response HTTP headers associated with this response.

Dictionary<string, string> Headers { get; }

Property Value

Dictionary<string, string>

HeadersArray

An array with all the request HTTP headers associated with this response. Header names are not lower-cased. Headers with multiple entries, such as Set-Cookie, appear in the array multiple times.

IReadOnlyList<Header> HeadersArray { get; }

Property Value

IReadOnlyList<Header>

Ok

Contains a boolean stating whether the response was successful (status in the range 200-299) or not.

bool Ok { get; }

Property Value

bool

Status

Contains the status code of the response (e.g., 200 for a success).

int Status { get; }

Property Value

int

StatusText

Contains the status text of the response (e.g. usually an "OK" for a success).

string StatusText { get; }

Property Value

string

Url

Contains the URL of the response.

string Url { get; }

Property Value

string

Methods

BodyAsync()

Returns the buffer with response body.

Task<byte[]> BodyAsync()

Returns

Task<byte[]>

JsonAsync()

Returns the JSON representation of response body.

This method will throw if the response body is not parsable via JSON.parse.

Task<JsonElement?> JsonAsync()

Returns

Task<JsonElement?>

JsonAsync<T>(JsonSerializerOptions?)

Task<T?> JsonAsync<T>(JsonSerializerOptions? options = null)

Parameters

options JsonSerializerOptions

Returns

Task<T>

Type Parameters

T

TextAsync()

Returns the text representation of response body.

Task<string> TextAsync()

Returns

Task<string>