Skip to main content

#{}0 personne en discute

I am getting below error as I have a HTTP requester node where we have a PUT call so there is no response body.

 

So while creating inbound response we get below error on Transform node.

Unable to parse empty input, while reading `payload` as Json

 

If I do a setPaylod like below with empty body then it works.

<set-payload value="#{}" doc:name="Set Payload" doc:id="4d3edefb-a8c4-43af-bfa4-4625f536509f" />

 

However I am looking for a solution to handle this in the transform node itself.Unable to parse empty input, while reading `payload` as JsonPlease let me know how to handle this in transform node in the best possible way ?

11 réponses
0/9000

I have a flow that has the Salesforce create connector, the Munit test that references the flow Runs fine locally. But when I try to deploy them to the CloudHub using the Azure Devops CI/CD pipeline throws error like

 

WARN 2022-04-07 23:41:54,103 [[MuleRuntime].uber.04: [mule-salesforce-sys].salesforce-Opportunity-create-flow/processors/3.ps.BLOCKING @3c7baec] org.mule.extension.salesforce.internal.connection.provider.BasicConnectionProvider: Couldn't obtain access token because an exception has occurred. Runtime to handle the ConnectionException. Root exception was: Invalid status code: 400, response body: {"error":"invalid_client","error_description":"invalid client credentials"}

 

.

 

org.mule.runtime.extension.api.exception.ModuleException: Invalid status code: 400, response body: {"error":"invalid_client","error_description":"invalid client credentials"}

 

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

Invalid status code: 400, response body: {"error":"invalid_client","error_description":"invalid client credentials"}

 

But before I created the Munit tests I deployed the flow to the CloudHub and there was no issues or error. I can still access the endpoint. After adding the Munit tests and deploying it throws error. All the credentials are stored in the Pipeline Variables..

 

And the Munit test

 

<munit:test name="salesforce-sys-implementation-test-suite-salesforce-Opportunity-create-flowTest" doc:id="c9779a45-00fe-4e08-b3e7-2580e68352ef" description="Test">

<munit:behavior>

<munit-tools:mock-when doc:name="Mock when" doc:id="a2ff9717-a4ee-4bea-9caf-9e3d5fe591b7" processor="flow">

<munit-tools:with-attributes >

<munit-tools:with-attribute whereValue="post:\opportunity:application\json:salesforce-system-api-config" attributeName="name" />

</munit-tools:with-attributes>

<munit-tools:then-return >

<munit-tools:payload value="#{}" mediaType="application/json" encoding="UTF-8" />

</munit-tools:then-return>

</munit-tools:mock-when>

</munit:behavior>

<munit:execution >

<munit:set-event doc:name="Set Event" doc:id="4c21ba83-a2d8-47f7-a327-33a772f980c6" >

<munit:payload value='{

&#10; "name": "X",

&#10; "SowGenerationStage": "SOW Requested",

&#10; "dateOfFirstContact": "2022-03-28",

&#10; "closeDate": "2022-03-28",

&#10; "SowRequestDate": "2022-03-28T12:48:16Z",

&#10; "accountId": "001T7IAM",

&#10; "contact": "003U0",

&#10; "leadSource": "Project Management",

&#10; "recordTypeId": "012U0000000QBXWIA4",

&#10; "serviceType": "SPR",

&#10; "priceBook2ID": "01s",

&#10; "stageName": "Discover"

&#10;}' mediaType="application/json" />

</munit:set-event>

<flow-ref doc:name="Flow-ref to salesforce-Opportunity-create-flow" doc:id="3c3d043f-f1ad-4b8d-9290-d407400d14a6" name="salesforce-Opportunity-create-flow"/>

</munit:execution>

<munit:validation >

<munit-tools:assert-that doc:name="Assert that Not Null Response" doc:id="da165ba2-619f-462e-8278-e66ee771cb08" is="#MunitTools::notNullValue()" expression="#payload.Id"/>

</munit:validation>

</munit:test>

6 réponses
  1. 8 avr. 2022, 21:47

    Hello,

     

    Please select the correct processor in MUnit Mock component. I am sure It will work. I checked your attachment it was wrong.

     

    Sample below: Working

     

    Hello, Please select the correct processor in MUnit Mock component. I am sure It will work. I checked your attachment it was wrong.

0/9000

Hi,

I have a dynamic payload,

Would like to send the email with dynamic attachments while looping through the payload array.

My sample payload below

{

"attachments": [{

"fileType": "txt",

"fileName": "textattachment.txt",

"values": "This is the First email text attachment for NG"

}

{

"fileType": "txt",

"fileName": "sectextattachment.txt",

"values": "This is the Secondemail text attachment for NG"

}

]

}

 

Attachment payload will be dynamic and some time it can have single attachment and some time it has multiple attachments with txt ,csv types.

In single email I want to have all the attachments of payload

How I can loop through this payload and send the attachments.

Is it possible to Payload Map inside Send connector attachment section?.

 

Thanks in advance

--

Naveen G

1 réponse
  1. 1 févr. 2022, 22:40

    I just saw this question, I am sure you might have resolved it. Just adding my response in case anyone else looking for.

     

    //Create an empty map

    <set-variable value="#{}" doc:name="Set Variable" doc:id="4174b647-2b19-4803-bd16-f88cb7e910d1" variableName="fileList"/>

     

    //iterate over attachement list

    <foreach doc:name="For Each" doc:id="c166af5e-5c74-4157-90a4-e23cea3102f5" collection="#payload.attachment">

    <file:read doc:name="Read" doc:id="330f2166-d2b1-43f8-be7c-de132f92b7c7" config-ref="File_Config" path="#payload.name" target="tempAttach" />

    <ee:transform doc:name="Transform Message" doc:id="6610f4eb-3ce2-4832-9ef5-72d3f9492bff">

    <ee:message>

    </ee:message>

    <ee:variables>

    <ee:set-variable variableName="fileList"><![CDATA[%dw 2.0

    import * from dw::core::Binaries

    output application/java

    ---

    vars.fileList ++ {

    (payload.name) : toBase64(vars.tempAttach)

    }]]></ee:set-variable>

    </ee:variables>

    </ee:transform>

    </foreach>

     

    ------------------------------------------

     

    in SMTP connector use following to iterate the map and add attachement

    %dw 2.0

    output application/java

    ---

    vars.fileLIst mapObject ((value, key, index) -> 

    {

       (key) : value

    })

0/9000