Http API
English API reference for the http family.
This page is the primary owner for the namespaces listed below. Method names, parameter keys, and return fields follow the C++ RegisterApi handlers.
http
http.abort
| Parameter | Type | Required | Description |
|---|---|---|---|
requestId | string | Yes | The requestId returned by an async request. |
Returns: {"cancelled":"...","error":"...","requestId":"...","success":true}
const { requestId } = await fb2k.invoke('http.get', { url: 'https://example.com/large' });
await fb2k.invoke('http.abort', { requestId });http.delete
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
url | string | Yes | — | Request URL. |
body | json | No | — | Objects and arrays are serialized automatically. |
headers | object | No | {} | |
timeout | integer | No | 30000 | |
async | boolean | No | true | |
redirect | string | No | follow | |
responseType | string | No | text | |
insecureTls | boolean | No | false |
Returns: {"async":"...","error":"...","requestId":"...","success":true}
await fb2k.invoke('http.delete', { url: 'https://example.com/api/items/1' });http.download
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
url | string | Yes | — | Source URL. |
saveTo | string | Yes | — | Destination path; subject to the Bridge security policy. |
headers | object | No | — | |
timeout | integer | No | 60000 | |
async | boolean | No | false | Unlike other verbs, defaults to synchronous. |
redirect | string | No | follow | |
insecureTls | boolean | No | false |
Returns: {"async":"...","code":"...","error":"...","message":"...","requestId":"...","success":true}
Unlike the other http methods, async defaults to false here, so the call resolves only once the file is written.
const result = await fb2k.invoke('http.download', {
url: 'https://example.com/cover.jpg',
saveTo: 'C:\\Temp\\cover.jpg',
});http.get
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
url | string | Yes | — | Request URL. |
headers | object | No | — | |
timeout | integer | No | 30000 | |
async | boolean | No | true | |
redirect | string | No | follow | |
responseType | string | No | text | |
insecureTls | boolean | No | false |
Returns: {"async":"...","error":"...","requestId":"...","success":true}
// async is the default: the response arrives on the http:response event
const { requestId } = await fb2k.invoke('http.get', { url: 'https://example.com/api' });
// pass async: false to receive status, headers, and body directly
const res = await fb2k.invoke('http.get', { url: 'https://example.com/api', async: false });http.head
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
url | string | Yes | — | Request URL. |
headers | object | No | — | |
timeout | integer | No | 30000 | |
async | boolean | No | true | |
redirect | string | No | follow | |
insecureTls | boolean | No | false |
Returns: {"async":"...","contentLength":"...","requestId":"...","success":true}
contentLength is present only on a synchronous call whose response carried that header.
const res = await fb2k.invoke('http.head', { url: 'https://example.com/file.zip', async: false });http.patch
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
url | string | Yes | — | Request URL. |
body | json | No | — | Request body. |
headers | object | No | {} | |
timeout | integer | No | 30000 | |
async | boolean | No | true | |
redirect | string | No | follow | |
responseType | string | No | text | |
insecureTls | boolean | No | false |
Returns: {"async":"...","error":"...","requestId":"...","success":true}
await fb2k.invoke('http.patch', {
url: 'https://example.com/api/items/1',
body: { rating: 5 },
headers: { 'Content-Type': 'application/json' },
});http.post
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
url | string | Yes | — | Request URL. |
body | json | No | — | Request body. |
headers | object | No | {} | |
timeout | integer | No | 30000 | |
async | boolean | No | true | |
redirect | string | No | follow | |
responseType | string | No | text | |
insecureTls | boolean | No | false |
Returns: {"async":"...","error":"...","requestId":"...","success":true}
await fb2k.invoke('http.post', {
url: 'https://example.com/api/items',
body: { title: 'New item' },
headers: { 'Content-Type': 'application/json' },
});http.put
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
url | string | Yes | — | Request URL. |
body | json | No | — | Objects and arrays are serialized automatically. |
headers | object | No | {} | |
timeout | integer | No | 30000 | |
async | boolean | No | true | |
redirect | string | No | follow | |
responseType | string | No | text | |
insecureTls | boolean | No | false |
Returns: {"async":"...","error":"...","requestId":"...","success":true}
await fb2k.invoke('http.put', {
url: 'https://example.com/api/items/1',
body: { title: 'Updated' },
headers: { 'Content-Type': 'application/json' },
});Request lifecycle and security
http.get,http.post,http.put,http.delete,http.patch, andhttp.headdefault to asynchronous execution. Their immediatesuccess: trueresponse means only that dispatch succeeded and containsrequestId; it is not the HTTP result. Final results are sent to the invoking window ashttp:responseand must be correlated byrequestId.- The SDK
fb.http.request()helper waits for the matching completion event; use it when application code needs an awaited final result without manually subscribing tohttp:response. - The SDK convenience call
fb.http.get(is a facade over the same invoke contract and may decode binary response bodies for its caller. - For synchronous execution, pass
async: false. Successful non-download responses includestatus,headers,body, andresponseType. A successful synchronous or asynchronous HEAD response may additionally include numericcontentLengthwhen the response exposesContent-Length. http.downloaddefaults to synchronous execution. Withasync: true, its final result is emitted ashttp:downloadCompletewithrequestId;http.abortrequests cancellation of an active asynchronous request.- Only
httpandhttpsURLs are accepted. Private or local-network destinations are denied unless the host's Advanced Settings permits them; redirects are checked again at every hop and the redirect limit is 10. insecureTls: truetakes effect only when the caller opts in and the host's invalid-certificate setting is enabled. This bypass is unsuitable for public Internet traffic.- Response bodies are limited to 100 MB and downloads to 500 MB.
http.download.saveTois a write-protected path parameter and is subject to the Bridge security policy.