JSONStreamingBuilder - Scoped
-
- UpdatedJan 30, 2025
- 6 minutes to read
- Yokohama
- API reference
Create a builder object used to build a large streaming JSON payload to use in a REST or SOAP request to send bulk data to a third-party API. You can also create the payload as a JSON string for a non-streaming option.
Use these methods in the Workflow Studio script step with the sn_ih
namespace
identifier. For example, you can use this API to create a JSON payload in the Workflow Studio Script step and pass the returned value to the REST step
to send the request to a third-party service. For more information, see the Workflow Studio
Script
step.
You can only use this API within the Workflow Studio environment.
API call order
Generate JSON payloads using these APIs in the following order:
- JSONStreamingBuilder: Creates a builder object
- Use these methods in the following order to create a builder object:
- JSONStreamingBuilder(): Instantiates the JSONStreamingBuilder object.
- withAttachment(): Optional. Creates the JSON object as a streaming attachment and stores it in the Streaming Attachments [streaming_attachment] table. If you do not call this method, the API creates the payload as a JSON string.
- expiresAt(): Optional. Sets a time when the attachment expires. Must also call the withAttachment() method.
- build(): Returns a JSONStreamingAPI object.
- JSONStreamingAPI: Builds the JSON payload
- Use these methods in the following order to create the JSON payload:
- startObject(): Creates the parent JSON object.
- Methods to generate the JSON key-value pairs, such as writeFieldName(), writeString(), and writeNumberField().
- endObject(): Closes the parent JSON object.
- getJSONString() or getAttachmentId(): Returns the JSON string or attachment ID that you created.
- close(): Closes the JSONStreamingAPI object.
Size limits
Payloads generated through this API cannot exceed these size limits:
- Attachments: 200 MB
- Strings: 5 MB
Examples
This example shows how to create a JSON object and store it in the Attachment [sys_attachment] table with a defined expiration date.
Alternatively, this example shows how to use the API in the Script step and create the payload as a JSON string. You can use this option to create payloads under 5 MB.
Output:
JSONStreamingBuilder - JSONStreamingBuilder()
Instantiates the JSONStreamingBuilder object.
Name | Type | Description |
---|---|---|
None |
Example
JSONStreamingBuilder - build()
Returns a JSONStreamingAPI object.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
JSONStreamingAPI | Streaming JSON object used to construct the payload. |
Example
This example shows how to create a JSON object and store it in the Attachment [sys_attachment] table with a defined expiration date.
JSONStreamingBuilder - expiresAt(Object expiresAt)
Sets a time when the attachment expires. Must also call the withAttachment() method. If you do not call this method, the attachment expires two hours from the time the attachment is created.
Name | Type | Description |
---|---|---|
expiresAt | GlideDateTime | Object that is set when the attachment expires.
|
Type | Description |
---|---|
JSONStreamingBuilder | Builder object used to initiate the JSON payload. |
Example
This example shows how to create a JSON object and store it in the Attachment [sys_attachment] table with a defined expiration date.
JSONStreamingBuilder - withAttachment()
Creates the JSON object as a streaming attachment and stores it in the Streaming Attachments [streaming_attachment] table. If you do not call this method, the API creates the payload as a JSON string.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
JSONStreamingBuilder | Builder object used to initiate the JSON payload. |
Example
This example shows how to build the JSON payload and save it as an attachment.
Example
This example shows how to build the JSON payload and save it as a string.