APIRequest
Exposes API that can be used for the Web API testing. This class is used for creating APIRequestContext instance which in turn can be used for sending web requests. An instance of this class can be obtained via Playwright.APIRequest. For more information see APIRequestContext.
Methods
NewContextAsync
Added in: v1.16Creates new instances of APIRequestContext.
Usage
await ApiRequest.NewContextAsync(options);
Arguments
options
ApiRequestNewContextOptions?
(optional)-
Methods like ApiRequestContext.GetAsync() take the base URL into consideration by using the
URL()
constructor for building the corresponding URL. Examples:- baseURL:
http://localhost:3000
and sending request to/bar.html
results inhttp://localhost:3000/bar.html
- baseURL:
http://localhost:3000/foo/
and sending request to./bar.html
results inhttp://localhost:3000/foo/bar.html
- baseURL:
http://localhost:3000/foo
(without trailing slash) and navigating to./bar.html
results inhttp://localhost:3000/bar.html
- baseURL:
-
ExtraHTTPHeaders
IDictionary?<string, string> (optional)#An object containing additional HTTP headers to be sent with every request. Defaults to none.
-
HttpCredentials
HttpCredentials? (optional)#-
Username
string -
Password
string -
Origin
string? (optional)Restrain sending http credentials on specific origin (scheme://host:port).
Credentials for HTTP authentication. If no origin is specified, the username and password are sent to any servers upon unauthorized responses.
-
-
IgnoreHTTPSErrors
bool? (optional)#Whether to ignore HTTPS errors when sending network requests. Defaults to
false
. -
Proxy
Proxy? (optional)#-
Server
stringProxy to be used for all requests. HTTP and SOCKS proxies are supported, for example
http://myproxy.com:3128
orsocks5://myproxy.com:3128
. Short formmyproxy.com:3128
is considered an HTTP proxy. -
Bypass
string? (optional)Optional comma-separated domains to bypass proxy, for example
".com, chromium.org, .domain.com"
. -
Username
string? (optional)Optional username to use if HTTP proxy requires authentication.
-
Password
string? (optional)Optional password to use if HTTP proxy requires authentication.
Network proxy settings.
-
-
StorageState
string? (optional)#Populates context with given storage state. This option can be used to initialize context with logged-in information obtained via BrowserContext.StorageStateAsync() or ApiRequestContext.StorageStateAsync(). Either a path to the file with saved storage, or the value returned by one of BrowserContext.StorageStateAsync() or ApiRequestContext.StorageStateAsync() methods.
-
StorageStatePath
string? (optional) Added in: v1.18#Populates context with given storage state. This option can be used to initialize context with logged-in information obtained via BrowserContext.StorageStateAsync(). Path to the file with saved storage state.
-
Timeout
[float]? (optional)#Maximum time in milliseconds to wait for the response. Defaults to
30000
(30 seconds). Pass0
to disable timeout. -
Specific user agent to use in this context.
-
Returns