rbv_api.sendJSONRequest()
Purpose
Sends a JSON request to the specified URL and returns the HTTP response body.
Syntax
rbv_api.sendJSONRequest(url,
data, method,
contentType, username, password, headers, retryParams)
Parameters
url
URL to send an HTTP request
data
Text string or a JSON object to send as a body of the request
method
HTTP method, one of GET (default), POST, PUT or DELETE
contentType
MIME content type of data. For example:
application/json; charset=UTF-8(default)
username
Login name for BASIC authentication, by default null
password
Password for BASIC authentication, by default null
headers
Optional array of HTTP headers in name/value pairs, by default null
retryParams
Optional JSON object that includes the following mandatory retry options for trigger.
- numRetries — Number of retries allowed for a trigger. The maximum number of retries must not exceed 3.
- retryInterval — Interval (ms)
between two subsequent retries. The maximum retry timeout value (Retry Interval *
Number of retries) can be configured using
MaxHttpRetryTimeoutInMinsshared.property. Default value ofMaxHttpRetryTimeoutInMinsis 1 min. - statusCodes — HTTP Response codes on which retry should happen. It can be a comma separated values of status codes as well as a range of status codes. For example, 302-400,500.
Return value
Body of HTTP response
Example
rbv_api.sendJSONRequest
("http://www.infiniteblue.com/master/system/ri.jsp",
'{"data":"data"}', "POST", "UTF-8", "admin2@1",
"welcome", "",'{ "numRetries" : "3","retryInterval" : "1000",
"statusCodes" : "200-300,400,500"}');
Support for Base64 Encoding of Binary HTTP Responses
Binary Response Handling (Base64 Encoding)
Previously, all HTTP APIs within the platform returned strings. When remote endpoints sent binary content, converting bytes to text corrupted the data, complicating file downloads and input to binary field APIs requiring Base64.
The Infinite Blue Platform HTTP APIs now support binary and other non-text response types via an optional request header. This enhancement prevents data corruption when processing files such as PDFs, Excel, Word documents, or images.
All HTTP APIs now accept this optional request header:
| Header | Value |
|---|---|
|
Content Transfer Encoding |
base64 (case-insensitive) |
When this header is included in the request:
-
The API reads the response body as raw bytes.
-
The API returns a Base64-encoded string of those bytes instead of decoding the content as text.
-
The returned Base64 value is compatible with existing binaryField API methods.
When the header is not included, all APIs behave as they do currently, returning responses as plain text strings.
| Header availability | Response format |
|---|---|
|
Yes (Content Transfer Encoding: base64) |
Base64-encoded string of raw response bytes |
| No |
Standard string response (existing behavior) |
Example (Server-Side JavaScript)
Downloading a PDF and saving it to a binary field:
var url = "{!DownloadURL}";var method = "GET";
var headers = {"Content-Type": "application/pdf",
"Content-Transfer-Encoding": "base64"
};
var params = null;
var body = null;
var options = null;
var resp = rbv_api.sendHttpRequest(url, method, headers, params, body, options);
// With Content-Transfer-Encoding=base64,
// resp.body contains a Base64-encoded string of the PDF bytes.
if (resp && resp.body) {var fileName = Date.now() + "." + "{!File_Extension}";rbv_api.setBinaryFieldValue(
"pdftestobj",
{!id},"fu1",
resp.body, // Base64 content returned from HTTP API
"application/pdf",
fileName
);
}
Header value matching is performed in a case-insensitive manner.
Only the response body is subject to modification. Status codes, headers, and associated metadata remain unchanged.
Scripts and integrations that do not transmit the Content-Transfer-Encoding: base64 header maintain compatibility.