class Playwright::APIResponse

“‘
assert response.body() == ’{“status”: “ok”}‘
assert response.json() == “foobar”
assert response.headers == “application/json; charset=utf-8”
assert response.status == 200
assert response.ok
response = context.get(“example.com/user/repos”)
context = playwright.request.new_context()
with sync_playwright() as p:
from playwright.sync_api import sync_playwright
“`python sync
`APIResponse` class represents responses returned by [`method: APIRequestContext.get`] and similar methods.

def body

Returns the buffer with response body.
def body
  wrap_impl(@impl.body)
end

def dispose

Disposes the body of this response. If not called then the body will stay in memory until the context closes.
def dispose
  wrap_impl(@impl.dispose)
end

def headers

An object with all the response HTTP headers associated with this response.
def headers
  wrap_impl(@impl.headers)
end

def headers_array

Headers with multiple entries, such as `Set-Cookie`, appear in the array multiple times.
An array with all the request HTTP headers associated with this response. Header names are not lower-cased.
def headers_array
  wrap_impl(@impl.headers_array)
end

def json

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

Returns the JSON representation of response body.
def json
  wrap_impl(@impl.json)
end

def ok

Contains a boolean stating whether the response was successful (status in the range 200-299) or not.
def ok
  wrap_impl(@impl.ok)
end

def ok?

@nodoc
def ok?
  wrap_impl(@impl.ok?)
end

def status

Contains the status code of the response (e.g., 200 for a success).
def status
  wrap_impl(@impl.status)
end

def status_text

Contains the status text of the response (e.g. usually an "OK" for a success).
def status_text
  wrap_impl(@impl.status_text)
end

def text

Returns the text representation of response body.
def text
  wrap_impl(@impl.text)
end

def to_s

@nodoc
def to_s
  wrap_impl(@impl.to_s)
end

def url

Contains the URL of the response.
def url
  wrap_impl(@impl.url)
end