'Retrieve Metadata connector resulting in error - Unable to parse the unpackaged stream
Based on the comment here I am trying to use retrieve metadata connector in Mulesoft to achieve the description of an Object.
- Created a package.xml
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>*</members>
<name>CustomObject</name>
</types>
<version>54.0</version>
</Package>
- Documentation suggests that in order to use
Unpackagedfield the format should beBinary. Hence I read the package.xml file and then converted it to Binary format using this dwl
%dw 2.0
output text/plain
import dw::Crypto
---
Crypto::hashWith(write(payload,"application/xml"),'MD5')
Reference: Object-Binary
- Below is what I configured in the connector
Retrieve Metadata Connector Config
<salesforce:retrieve-metadata doc:name="Retrieve metadata" doc:id="d2aa6e13-3012-4e53-a448-3c00f5058f55" config-ref="Salesforce_Config" unpackaged="#[payload]" />
This results in the below stack trace
********************************************************************************
Message : Unable to parse the unpackaged stream
Element : sf-testFlow/processors/2 @ sf-test:sf-test.xml:74 (Retrieve metadata)
Element DSL : <salesforce:retrieve-metadata doc:name="Retrieve metadata" doc:id="d2aa6e13-3012-4e53-a448-3c00f5058f55" config-ref="Salesforce_Config" unpackaged="#[payload]"></salesforce:retrieve-metadata>
Error type : MULE:UNKNOWN
FlowStack : at sf-testFlow(sf-testFlow/processors/2 @ sf-test:sf-test.xml:74 (Retrieve metadata))
--------------------------------------------------------------------------------
Root Exception stack trace:
org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
Not sure the connector expects this type of format? or whether this approach is wrong?
Solution 1:[1]
You are not converting the XML to binary, you are digitally hashing it, which makes it impossible to recover the original content. Basically it is encrypting the content and throwing away the key.
Have you tried instead the <salesforce:read-metadata> operation? Reference https://docs.mulesoft.com/salesforce-connector/10.11/salesforce-connector-reference#ReadMetadata
Example:
<salesforce:read-metadata type="CustomObject" config-ref="config">
<salesforce:full-names><![CDATA[#[["Lead"]]]]></salesforce:full-names>
</salesforce:read-metadata>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | aled |

