APIResponse
Source URL: https://playwright.dev/docs/api/class-apiresponse
APIResponse | Playwright
Section titled “APIResponse | Playwright”APIResponse class represents responses returned by apiRequestContext.get() and similar methods.
Methods
Section titled “Methods”Added in: v1.16 apiResponse.body
Returns the buffer with response body.
Usage
await apiResponse.body();Returns
dispose
Section titled “dispose”Added in: v1.16 apiResponse.dispose
Disposes the body of this response. If not called then the body will stay in memory until the context closes.
Usage
await apiResponse.dispose();Returns
headers
Section titled “headers”Added in: v1.16 apiResponse.headers
An object with all the response HTTP headers associated with this response.
Usage
apiResponse.headers();Returns
headersArray
Section titled “headersArray”Added in: v1.16 apiResponse.headersArray
An array with all the response 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.
Usage
apiResponse.headersArray();Returns
Name of the header.
* `value` [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type "string")Value of the header.
Added in: v1.16 apiResponse.json
Returns the JSON representation of response body.
This method will throw if the response body is not parsable via JSON.parse.
Usage
await apiResponse.json();Returns
Added in: v1.16 apiResponse.ok
Contains a boolean stating whether the response was successful (status in the range 200-299) or not.
Usage
apiResponse.ok();Returns
Added in: v1.16 apiResponse.status
Contains the status code of the response (e.g., 200 for a success).
Usage
apiResponse.status();Returns
statusText
Section titled “statusText”Added in: v1.16 apiResponse.statusText
Contains the status text of the response (e.g. usually an “OK” for a success).
Usage
apiResponse.statusText();Returns
Added in: v1.16 apiResponse.text
Returns the text representation of response body.
Usage
await apiResponse.text();Returns
Added in: v1.16 apiResponse.url
Contains the URL of the response.
Usage
apiResponse.url();Returns