Anypoint Studio Salesforce Analytics Connector - Unable to Upload and Process Dataset

56 Views Asked by At

I am really hoping someone can help.

I am extracting an array of data via HTTP Request and I need to create a dataset and insert the data daily in CRM Analytics.

I have added the Salesforce Analytics Connector and followed all instructions I can find online, but I cannot find any with clear instructions and examples and I keep getting errors.

The error I am receiving at the moment is:

Message        : "Cannot coerce Object { encoding: UTF-8, mediaType: application/json; charset=UTF-8, mimeType: application/json, raw: org.mule.weave.v2.el.SeekableCursorStream@332831d7 } ({data: {homeLoans: [{additionalRepayments: "yes - free",applicationFee: 600.0...) to Array" evaluating expression: "vars.payloadv".

Element        : mozo-home-loanFlow/processors/4 @ mozo-home-loan:mozo-home-loan.xml:104 (Upload external data into new data set and start processing)

Element DSL      : <salesforce-analytics:upload-external-data-into-new-data-set-and-start-processing operation="UPSERT" doc:name="Upload external data into new data set and start processing" doc:id="0fe67a61-e820-4751-b984-7c0c82707bdc" config-ref="Salesforce_Analytics_Config" description="test mozo" label="test mozo home loan" dataSetName="Mozo Home Loan" target="temp" type="H:\MOZO API Workspace\mozo-home-loan\homeLoanDatasetScheme.json">

<salesforce-analytics:records><![CDATA[

#[vars.payloadv]

]]></salesforce-analytics:records>

</salesforce-analytics:upload-external-data-into-new-data-set-and-start-processing>

Error type      : MULE:EXPRESSION

FlowStack       : at mozo-home-loanFlow(mozo-home-loanFlow/processors/4 @ mozo-home-loan:mozo-home-loan.xml:104 (Upload external data into new data set and start processing))

Here is what I have done so far:

  • After the HTTP Request element, I have Upload external data into new dataset and start processing element enter image description here
  • Within this element I have the following config (the record vars.payloadv being the output variable from the http request element): enter image description here
  • I have selected the Type from a file I have saved but I would rather do this via another method as I will not be able to access this file once it is deployed to Cloudhub. The json for the Type (dataset scheme) is as follows:
{

"fileFormat": {

    "charsetName": "UTF-8",

    "fieldsDelimitedBy": ",",

    "linesTerminatedBy": "\r\n"

},

"objects": [

    {

        "connector": "CSV",

        "fullyQualifiedName": "datasetschema_csv",

        "label": "datasetschema_csv",

        "name": "datasetschema_csv",

        "fields": [

            {

                "fullyQualifiedName": "additionalRepayments",

                "name": "additionalRepayments",

                "type": "Text",

                "label": "additionalRepayments"

        },

        {

            "fullyQualifiedName": "applicationFee",

            "name": "applicationFee",

            "type": "Numeric",

            "label": "applicationFee"

    },

    {

        "fullyQualifiedName": "borrowerType",

        "name": "borrowerType",

        "type": "Text",

        "label": "borrowerType"

},

{

    "fullyQualifiedName": "comparisonRateFixed1Year",

    "name": "comparisonRateFixed1Year",

    "type": "Numeric",

    "label": "comparisonRateFixed1Year"

}......etc continuing for all fields

The payload received from the HTTP Requester is in the format below (I am not including full payload as it is too long, but it is returning an array of data from an external website that I have an API connection to)

{

  "data": {

    "homeLoans": [

      {

        "additionalRepayments": "yes - free",

        "applicationFee": 600,

        "borrowerType": "Owner Occupier, Investor",

        "comparisonRateFixed1Year": null,

        "comparisonRateFixed2Year": null,

        "comparisonRateFixed3Year": null,

        "comparisonRateFixed4Year": null,

        "comparisonRateFixed5Year": null,

        "comparisonRateVariable": 9.44,

        "dischargeFee": 115,

        "fixed1YearRate": null

}

]

}

}

XML from my flow is as follows:

    <?xml version="1.0" encoding="UTF-8"?>

    <mule xmlns:salesforce-analytics="http://www.mulesoft.org/schema/mule/salesforce-analytics" 
    xmlns:http="http://www.mulesoft.org/schema/mule/http"
    xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
    xmlns="http://www.mulesoft.org/schema/mule/core" 
    xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core 
    http://www.mulesoft.org/schema/mule/core/current/mule.xsd
    http://www.mulesoft.org/schema/mule/ee/core 
    http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
    http://www.mulesoft.org/schema/mule/http 
    http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
    http://www.mulesoft.org/schema/mule/salesforce-analytics 
    http://www.mulesoft.org/schema/mule/salesforce-analytics/current/mule-salesforce-analytics.xsd">
    <http:request-config name="HTTP_Request_configuration" doc:name="HTTP Request configuration" doc:id="93e48a36-4475-4596-bc37-481c72908d24" />
    <salesforce-analytics:salesforce-analytics-config name="Salesforce_Analytics_Config" doc:name="Salesforce Analytics Config" doc:id="12a138b2-35a2-4d46-a7af-075ff66213d4" >
    <salesforce-analytics:basic-connection username=****** password=****** securityToken=****** />
    </salesforce-analytics:salesforce-analytics-config>
    <flow name="analytics-connector-testFlow" doc:id="cac2b44d-3284-483e-990e-e46242cfefd3" >
    <scheduler doc:name="Scheduler" doc:id="6fe7ec38-d803-4437-9482-5ad7a6e792df" >
    <scheduling-strategy >
    <fixed-frequency />
    </scheduling-strategy>
    </scheduler>
    <set-variable value="#[output application/json&#10;---&#10;now()]" doc:name="Set Variable" doc:id="5dbab7f0-c615-4966-8628-4f93eac46fa6" variableName="DateExtracted"/>
    <ee:transform doc:name="Transform Message" doc:id="25812c4e-8c88-4d7d-a4d7-74c1c7197a31" >
    <ee:message >
    <ee:set-payload ><![CDATA[%dw 2.0
    output application/json
    ---
    {
    query: "query {
    homeLoans
    (limit: 1)

    {
    additionalRepayments
    applicationFee
    borrowerType
    comparisonRateFixed1Year
    comparisonRateFixed2Year
    comparisonRateFixed3Year
    comparisonRateFixed4Year
    comparisonRateFixed5Year
    comparisonRateVariable
    dischargeFee
    fixed1YearRate
    fixed2YearRate
    fixed3YearRate
    fixed4YearRate
    fixed5YearRate
    fixedLoanRevertRate
    id
    introductoryInterestRate
    introductoryRate
    introductoryRateTermMonths
    introductoryRateType
    isFhbOnly
    lastFixed1YearRateChange
    lastFixed1YearRateChangedAt
    lastFixed2YearRateChange
    lastFixed2YearRateChangedAt
    lastFixed3YearRateChange
    lastFixed3YearRateChangedAt
    lastFixed4YearRateChange
    lastFixed4YearRateChangedAt
    lastFixed5YearRateChange
    lastFixed5YearRateChangedAt
    lastIntroductoryRateChange
    lastIntroductoryRateChangedAt
    lastVariableRateChange
    lastVariableRateChangedAt
    legalFee
    loanOrLineOfCredit
    maximumLoanAmount
    maximumLvr
    minimumLoanAmount
    minimumLvr
    minimumRedraw
    name
    offsetAccountDetails
    onSiteDisplay
    ongoingFee
    ongoingFeeAmount
    ongoingFeeFrequency
    otherBenefits
    otherRestrictions
    providerGroupName
    providerId
    providerLogo
    providerLogoLarge
    providerLogoOriginal
    providerName
    redrawFacility
    repaymentTypes
    settlementFee
    specialOffers
    splitLoanAvailable
    upfrontFee
    valuationFee
    variableRate
    }
    }"
    }]]>
    </ee:set-payload>
    </ee:message>
    </ee:transform>
    <http:request method="POST" doc:name="Request" doc:id="7e17c6d0-04f6-4e62-9f6c-dba84e5fe993" 
    url="https://marketview.mozo.com.au/graphql/5955d03f1fdc" config-ref="HTTP_Request_configuration" target="payloadv"/>
    <salesforce-analytics:upload-external-data-into-new-data-set-and-start-processing doc:name="Upload external data into new data set and start processing" doc:id="1ff88f27-1816-4553-8d56-4a3b8de54571" config-ref="Salesforce_Analytics_Config" type="H:\VS Code\Mozo\homeLoanDatasetScheme.json" operation="UPSERT" description="Test CRMA Connection" label="Test Mozo Home Loan" dataSetName="Mozo Home Loan">
    <salesforce-analytics:records ><![CDATA[#[vars.payloadv]]]></salesforce-analytics:records>
    </salesforce-analytics:upload-external-data-into-new-data-set-and-start-processing>
    <logger level="INFO" doc:name="Logger" doc:id="4f9ad7bf-d491-4a2d-a8e8-0811db5ea6d2" message="#[vars.payloadv]"/>
    <error-handler >
    <on-error-continue enableNotifications="true" logException="true" doc:name="On Error Continue" doc:id="9f057cb0-9ef8-401d-9079-c24da1d15966" >
    <logger level="ERROR" doc:name="Logger" doc:id="da0ccb15-eb2d-4c13-9edd-051d41211325" />
    </on-error-continue>
    </error-handler>
    </flow>
    </mule>


Can someone please help with where I am going wrong? I can confirm that the connection with CRM Analytics works when tested and I successfully receive the payload from the endpoint when tested with a logger.

0

There are 0 best solutions below