new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Playwright · API reference · all subjects

apirequestcontext/methods

13 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

APIRequestContext.createFormData method

Method: createFormData() introduced in v1.23. Available in C#. Returns a FormData instance which is used for providing form and multipart data when making HTTP requests.

APIRequestContext.delete method

Async method introduced in v1.16. Sends HTTP(S) DELETE request and returns APIResponse. Populates request cookies from the context and updates context cookies from the response. Automatically follows redirects. Parameters: url (required), params, paramsString (v1.47), headers, data, form, multipart, timeout, signal, failOnStatusCode, ignoreHTTPSErrors, maxRedirects (v1.26), maxRetries (v1.46).

APIRequestContext.dispose method

Async method introduced in v1.16. Discards all resources of the APIRequestContext. All responses returned by get() and similar methods are stored in memory; this method releases those resources. Calling any method on a disposed APIRequestContext will throw an exception. Option: reason (string, v1.45) - the reason to be reported to operations interrupted by context disposal.

APIRequestContext.head method

Async method introduced in v1.16. Sends HTTP(S) HEAD request and returns APIResponse. Populates request cookies from the context and updates context cookies from the response. Automatically follows redirects. Parameters: url (required), params, paramsString (v1.47), headers, data (v1.26), form (v1.26), multipart (v1.26), timeout, signal, failOnStatusCode, ignoreHTTPSErrors, maxRedirects (v1.26), maxRetries (v1.46).

APIRequestContext.patch method

Async method introduced in v1.16. Sends HTTP(S) PATCH request and returns APIResponse. Populates request cookies from the context and updates context cookies from the response. Automatically follows redirects. Parameters: url (required), params, paramsString (v1.47), headers, data, form, multipart, timeout, signal, failOnStatusCode, ignoreHTTPSErrors, maxRedirects (v1.26), maxRetries (v1.46).

APIRequestContext.put method

Async method introduced in v1.16. Sends HTTP(S) PUT request and returns APIResponse. Populates request cookies from the context and updates context cookies from the response. Automatically follows redirects. Parameters: url (required), params, paramsString (v1.47), headers, data, form, multipart, timeout, signal, failOnStatusCode, ignoreHTTPSErrors, maxRedirects (v1.26), maxRetries (v1.46).

APIRequestContext.storageState method return type

Async method introduced in v1.16. Returns storage state containing current cookies and local storage snapshot if it was passed to the constructor. Return object structure: cookies (array of objects with properties: name, value, domain, path, expires [float, Unix time in seconds], httpOnly [boolean], secure [boolean], sameSite [SameSiteAttribute: "Strict"|"Lax"|"None"]), origins (array of objects with properties: origin [string], localStorage [array of objects with properties: name [string], value [string]]).

APIRequestContext.storageState method with path option

Async method introduced in v1.16, available in Java and C#. Returns storage state as a string. Option: path - file path to save storage state. Option: indexedDB (boolean, v1.51) - set to true to include IndexedDB in the storage state snapshot.

APIRequestContext fetch example with JSON data

Example showing how to send JSON data with fetch method. JSON objects can be passed directly to the request data option. Example code: js: await request.fetch('https://example.com/api/createBook', { method: 'post', data: { title: 'Book Title', author: 'John Doe' } }) python: api_request_context.fetch('https://example.com/api/createBook', method='post', data={'title': 'Book Title', 'body': 'John Doe'})

APIRequestContext get example with query parameters

Example showing how to pass query parameters with get method. JavaScript: await request.get('https://example.com/api/getText', { params: { 'isbn': '1234', 'page': 23 } }). Python: query_params = {'isbn': '1234', 'page': '23'}; api_request_context.get('https://example.com/api/getText', params=query_params). C#: var queryParams = new Dictionary<string, object>() { { 'isbn', '1234' }, { 'page', 23 } }; await request.GetAsync('https://example.com/api/getText', new() { Params = queryParams })

APIRequestContext post example with JSON data

Example showing how to send JSON data with post method. JavaScript: await request.post('https://example.com/api/createBook', { data: { title: 'Book Title', author: 'John Doe' } }). Python: data = {'title': 'Book Title', 'body': 'John Doe'}; api_request_context.post('https://example.com/api/createBook', data=data). C#: var data = new Dictionary<string, object>() { { 'firstName', 'John' }, { 'lastName', 'Doe' } }; await request.PostAsync('https://example.com/api/createBook', new() { DataObject = data })

APIRequestContext post example with form data

Example showing how to send form data with application/x-www-form-urlencoded encoding using post method. JavaScript: await request.post('https://example.com/api/findBook', { form: { title: 'Book Title', author: 'John Doe' } }). Python: formData = {'title': 'Book Title', 'body': 'John Doe'}; api_request_context.post('https://example.com/api/findBook', form=formData). C#: var formData = Context.APIRequest.CreateFormData(); formData.Set('title', 'Book Title'); formData.Set('body', 'John Doe'); await request.PostAsync('https://example.com/api/findBook', new() { Form = formData })

APIRequestContext post example with multipart file upload

Example showing how to upload files using multipart form data with post method. JavaScript: const form = new FormData(); form.set('name', 'John'); form.append('name', 'Doe'); form.append('file', new File(['console.log(2024);'], 'f1.js', { type: 'text/javascript' })); form.append('file', new File(['hello'], 'f2.txt', { type: 'text/plain' })); await request.post('https://example.com/api/uploadForm', { multipart: form }). Python: api_request_context.post('https://example.com/api/uploadScript', multipart={'fileField': {'name': 'f.js', 'mimeType': 'text/javascript', 'buffer': b'console.log(2022);'}})

Give your agent this brain