hubcap responsebody - Get the response body for a network request
When to use
Get the response body for a previously captured network request. Use the requestId from network or har output to identify which response to retrieve.
Usage
hubcap responsebody <requestId> Arguments
| Argument | Type | Required | Description |
|---|---|---|---|
requestId | string | Yes | Request identifier from network or har output |
Flags
None.
Output
The response body content object.
| Field | Type | Description |
|---|---|---|
body | string | Response body content |
base64Encoded | bool | Whether the body is base64-encoded |
{"body":"{\"status\":\"ok\",\"data\":[1,2,3]}","base64Encoded":false} Errors
| Condition | Exit code | Stderr |
|---|---|---|
| Missing requestId argument | 1 | usage: hubcap responsebody <requestId> |
| Protocol error | 1 | error: getting response body: ... |
| Chrome not connected | 2 | error: connecting to Chrome: ... |
| Timeout | 3 | error: timeout |
Examples
Get the response body for a specific request ID:
hubcap responsebody "1000.1" Extract the decoded body content:
hubcap responsebody "1000.1" | jq -r '.body' Capture network traffic and then retrieve the body for the first JSON response:
REQUEST_ID=$(hubcap network --duration 5s | jq -r 'select(.type == "response" and .mimeType == "application/json") | .requestId' | head -1)
hubcap responsebody "$REQUEST_ID" | jq -r '.body' | jq . See also
- network - Stream network requests and responses
- har - Capture network activity in HAR format
- intercept - Intercept and modify network requests or responses
- waitresponse - Wait for a specific network response