Posts

RAML with MultiPart

 Lets build to build file upload with MultiPart, below is RAML RAML /testUpload:      post:        description:  file upload to sftp        headers:         f ilePath:            description:  sftp file path            type:  string        body:          multipart/form-data:            properties:              fileName:                description:  file name                type:  string  ...

Mule4 - Dynamic Evaluate - Processor/Component

Image
 Dynamic Evaluate: The Dynamic Evaluate component/processor in Mule4 evaluates an expression to select DataWeave script , and then executes the new script to generate a result. This behavior enables you to dynamically select the script, instead of hardcoding it into the  Transform Message component based on condition. Usecase/scenario: 1. DataWeave script varies based on program id and its security id . 2. if there are 15 programs currently and may grow in future, In this scenario instead of writing if elseif condition based on program id and security id in a single dataweave script. 3. Modularize by  writing separate dwl script for each program id and security id combination. 4. Name each dataweave script such a way that program id and security id are part of it in order to resolve which script to dynamically evaluate at runtime. Example of dataweave without "Dynamic Evaluate" Component(illustration only): Example of dataweave with "Dynamic Evaluate" component: her...

DataWeave 2.0 Operator ~=

Image
 In DataWeave, the ~= operator determines if two values are similar, regardless of their type. for example: the string '123' and the number 123 are not equal, but they are recognized as similar or equal with  ~= operator. DataWeave:

Dataweave 2.0 read function

Image
 Converting String with escape characters (\), tab(\t), return (\r), new line (\n) to application/json. use read function. example

Dataweave 2.0 update function

Image
  Update the user data below. Usernames should be all lower case and the street should be   "Fiskargatan" (example from dataweave tutorial from mulesoft) Input payload { "username": "WASP", "name": "Lisbeth", "surname": "Salander", "location": { "address": { "street": "Lundagatan", "number": 9 }, "city": "Stockholm", "country": "Sweden" } } Dataweave Transformation %dw 2.0 import * from dw :: util :: Values output json --- payload update "username" with lower($) update [ "location" , "address" , field( "street" )] with "Fiskargatan" output { "username" : "wasp" , "name" : "Lisbeth" , "surname" : "Salander" , "location" : { "address...

Dataweave 2.0 - Pluck

Image
 Pluck is useful converting HashMap/Object into array of Objects.  pluck  iterates over an object and returns an array of keys, values, or indices from the object.

Dataweave 2.0(2.7) - typeOf

Image
 How to determine if the variable or payload type is String, Array, Number , Boolean or Object  using typeOf Object: String Number: Boolean: Array: