There are multiple ways you could process externally-stored XML data, here we will describe some common patterns on getting XML data into your integration flow.
You can send an XML Payload over HTTP and it will be accepted by the WebHook component. You can do this in two ways:
You can send your XML document as a Body via HTTP Post. Your HTTP request must have the following properties:
POST
,application/xml
,Here how you can post your XML data using curl
curl -X POST -H "Content-Type: application/xml" \
-d '<foo>Hello XML!</foo>' \
https://in.platform.address/hooks/your-hook
In this case, your XML document will be parsed and transformed into JSON document automatically (learn how to prevent automatic parsing). Resulting JSON Document will be used as placed in a body of your message and message will be sent to the next component in the flow. Here is how such message will look like:
{
"id": "2b90def0-d250-11e6-a2f1-5b2841bfd572",
"attachments": {},
"body": {
"foo": "Hello XML!"
},
"headers": {
"x-real-ip": "10.0.5.31, 10.0.5.31",
"host": "in.platform.address",
"x-forwarded-for": "10.0.5.31",
"x-nginx-proxy": "true",
"x-forwarded-proto": "https",
"connection": "upgrade",
"content-length": "21",
"user-agent": "curl/7.51.0",
"accept": "*/*",
"content-type": "application/xml"
}
}
Please Note: your XML payload will be automatically parsed and transformed to JSON and if it is an invalid XML document the platform will return
HTTP 400 "Bad Request"
error (e.g. close tag is missing).
In case you want avoid body transformation to JSON, the trigger consuming raw XML must define consumesRawData:true
in component.json. Please use raw
query parameter
(?raw=true
) like below:
curl -X POST -H "Content-Type: application/xml" \
-d '<foo>Hello XML!</foo>' \
https://in.platform.address/hooks/your-hook?raw=true
This works for any payload, including XML.
If you don’t like how XML is parsed and represented as JSON object or you would
like to preserve your XML file for further processing, then you can send your
XML file in attachment - using multipart/form-data
content type, so your HTTP
request must have the following properties:
POST
,multipart/form-data
,application/xml
,After receiving such HTTP request WebHook component will upload your file to the platform attachments storage and place a reference to it inside the attachments part of the generate message:
{
"id": "2b90def0-d250-11e6-a2f1-6b2841bfd574",
"attachments": {
"data.xml" : {
"url": "http://attachment_storage_URL/files/1cfc3a71-d7a7-44e6-a15e-ae18860d537c",
"content-type": "application/xml"
}
},
"body": {
},
"headers": {
"x-real-ip": "10.0.5.31, 10.0.5.31",
"host": "in.platform.address",
"x-forwarded-for": "10.0.5.31",
"x-nginx-proxy": "true",
"x-forwarded-proto": "https",
"connection": "upgrade",
"content-length": "21",
"user-agent": "curl/7.51.0",
"accept": "*/*",
"content-type": "application/xml"
}
}
Please Note: The platform will not parse your XML file. It will be temporarily stored for the next steps in the integration flow to pick and process this file. It is the responsibility of the following components to handle parsing/validation/transformation later.
You can read XML files from the external location, e.g. URI or FTP or any other file storage service. For example, you can take the SFTP component, every file SFTP component will find on your server will be sent as an attachment, similar to the sample above. If you would like to parse the attachments.