XMLStreamingBuilder - Scoped
-
- UpdatedFeb 1, 2024
- 5 minutes to read
- Washington DC
- API reference
Create a builder object to build a large XML payload for use in a REST or SOAP request to send bulk data to a third-party API. You can also create the payload as an XML string for a non-streaming option.
sn_ih
namespace identifier. For example,
you can use this API to create an XML payload in the Flow Designer
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 Flow Designer
Script
step.
API call order
Generate XML payloads by first instantiating a builder object with XMLStreamingBuilder and then calling the methods in the XMLStreamingAPI class:
- 1. XMLStreamingBuilder: Creates a builder object
- Use these method in the following order to create a builder object:
- XMLStreamingBuilder(): Instantiates the XMLStreamingBuilder object.
- withAttachment(): Optional. Creates an XML document as an attachment and stores it in the Streaming Attachments [streaming_attachment] table. If you don't call this method, the API builds the payload as an XML string.
- expiresAt(): Optional. Sets a time when the attachment expires. False is the default. Must also call the withAttachment() method.
- build(): Returns an XMLStreamingAPI object.
- 2. XMLStreamingAPI: Builds the XML payload
- Use these methods in the following order to create the XML payload:
- startDocument(): Creates the top-level parent element in the XML document.
- Methods to generate child elements in the XML document, such as writeTextElement(), startElement(), and writeArray().
- Methods to generate attributes for an element, such as writeAttribute(), writeNamespace(), and writeDtd().
- endElement(): Closes an XML element.
- endDocument: Closes the top-level parent element.
- getXMLString() or getAttachmentId(): Returns the XML string or attachment ID that you created.
- close(): Closes the XMLStreamingAPI object.
Size limits
Payloads generated through this API cannot exceed these size limits:
- Attachments: 200 MB
- Strings: 5 MB
Example
The following example shows how to create an XML document and store it in the Streaming Attachments [streaming_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 an XML string. You can use this option to create payloads under 5 MB.
Output:
XMLStreamingBuilder - build()
Returns an XMLStreamingAPI object.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
XMLStreamingAPI | Streaming XML object for constructing the payload. |
Example
The following example shows how to create an XML document and store it in the Streaming Attachments [streaming_attachment] table with a defined expiration date.
XMLStreamingBuilder - expiresAt(Object expiresAt)
Sets a time when the attachment expires. Must also call the withAttachment() method.
Name | Type | Description |
---|---|---|
expiresAt | GlideDateTime | Object that is set when the attachment expires.
|
Type | Description |
---|---|
XMLStreamingBuilder | Builder object used to initiate the XML payload. |
Example
The following example shows how to create an XML document and store it in the Streaming Attachments [streaming_attachment] table with a defined expiration date.
XMLStreamingBuilder - withAttachment()
Creates an XML document as an attachment and stores it in the Streaming Attachments [streaming_attachment] table. If you don't call this method, the API creates the XML document as a string.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
XMLStreamingBuilder | Builder object used to initiate the XML payload. |
Example
The following example shows how to create an XML document and store it in the Streaming Attachments [streaming_attachment] table with a defined expiration date.
This example shows how to build the XML payload and save it as a string.
Output:
XMLStreamingBuilder - XMLStreamingBuilder()
Instantiates the XMLStreamingBuilder object.
Name | Type | Description |
---|---|---|
None |
Example
This example shows how to instantiate a builder
object.