csvsalesforcedataweavemulesoftbulk-load

Mulesoft Salesforce Connector Error - (InvalidBatch : Failed to parse CSV. Not expecting more text after end quote)


I am trying to process a CSV file (separator = comma) that has columns with values containing comma, back-slash, forward-slash, double quotes.

Sample CSV:

Id,Name,RecordTypeId,Start_Date__c,Collab_Data
8701928,John Revor,2022-09-01,"[{""respId"":""a2s2i000000HoE0AAK"",""details"":""Test Data""},{""respId"":""30928HoE2AAK"",""details"":""Test Data""},{""respId"":""30928HoE4AAK"",""details"":""English""},{""respId"":""30928HoECAA0"",""details"":""Test Data""},{""respId"":""30928HoEEAA0"",""details"":""Test Data""},{""respId"":""30928HoEGAA0"",""details"":""Test Data""},{""respId"":""30928HoEIAA0"",""details"":""Test Data""},{""respId"":""30928HoE6AAK"",""details"":""Test Data""},{""respId"":""30928HoE8AAK"",""details"":""Test Data""},{""respId"":""30928HoEKAA0"",""details"":""Test Data""},{""respId"":""30928HoELAA0"",""details"":""Test Data""},{""respId"":""30928HoETAA0"",""details"":""Test Data""},{""respId"":""30928HoEOAA0"",""details"":""test communication""},{""respId"":""30928HoEVAA0"",""details"":""Excellent""},{""respId"":""30928HoEWAA0"",""details"":""Test Data 123""},{""respId"":""30928HoEXAA0"",""details"":""Test Data 435""},{""respId"":""30928HoEaAAK"",""details"":""[{\""respId\"":\""30928HoEbAAK\"",\""details\"":\""180\""},{\""respId\"":\""30928HoEcAAK\"",\""details\"":\""479\""},{\""respId\"":\""30928HoEZAA0\"",\""details\"":10.393117283950618}]""}]

I first configured the File Read connector for output-mime type as follows: File Read Connector

Then when setting for transformation to convert to java for further mapping logics, used the following dataweave:

%dw 2.0
input payload application/csv escape='"', quote='"'
output application/java
---
payload

Then finally before upserting to Salesforce using the Mulesoft Salesforce connector (Create job bulk api v 2), used the following dataweave:

%dw 2.0
output application/csv separator=",",quoteValues=true,escape=""
---
payload //Here there is some simple logic set which has not been posted here

But Salesforce is throwing the following error:

"InvalidBatch : Failed to parse CSV. Not expecting more text after end quote"

What could be causing the issue ?


Solution

  • You have made the escape character of your output csv as a blank character. Therefore it is not escaping the double quotes correctly that is included within the values.

    To use double quote as the escape character change the output derivative to

    output application/csv separator=",",quoteValues=true,escape='"'
    

    in your final Dataweave