Posts

Showing posts with the label MuleSoft ESB

Mule4 - Dataweave - use of read, fromBase64, valuesOf

Image
 Scenario: Assuming that there is base64 encoded string containing values separated by tab(\t) and each row is separated by new line(\n) without any headers, how to extract and build json with predefined index mapped to particular attribute name. Lets assume 0 index is firstName, 1st Index is lastName 2nd Index is customerId. Sample Data:   Mule\t Soft\t aa234ed23e Lets encode the above data to base64: TXVsZVx0U29mdFx0YWEyMzRlZDIzZQ== Now using dataweave functions read, fromBase64 and valueOf ,  extract and build json.

Mule4 - Resolving Database Date and DateTime Type Error while Inserting.

Let's see how to resolve error while inserting database date and datatime errors in Mule4 while inserting data into database. Column Declared as Date in database for the table example as follows: TRANDATE DATE DEFAULT '1970-01-01' NOT NULL, Dataweave : ( assuming the incoming  billing_date is coming as DateTime( example: "2024-02-06T11:02:05.237Z") and converting to Date in String format "yyyy-MM-dd" %dw 2.0 output application/json --- "billing_date": $.billing_date as DateTime {format: "yyyy-MM-dd'T'HH:mm:ss.SSSX"} as String {format : "yyyy-MM-dd"} , to convert RAML datetime type DB date time %dw 2.0 output application/json --- "date_updated" : $.date_updated as DateTime {         format : "yyyy-MM-dd'T'HH:mm:ss.SSSX"     } as DateTime {         format : "yyyy-MM-dd HH:mm:ss"     } error while executing :  "reason": "DB:QUERY_EXECUTION", "message...