Friday, May 21, 2021

Mulesoft - Extract Cookie value via Dataweave

Dataweave Hack - Read Cookie value from Cookie header

The following is a helpful Dataweave (2.0) code to allow you to extract cookie value coming in via Cookie header.

Script:

%dw 2.0
output application/java
---
(payload splitBy  "; " map ($ splitBy "=") reduce (item, accum = {}) -> (accum ++ { (item[0]): item[1] })) ['csrftoken']

Input

"PHPSESSID=413; csrftoken=444t4#tb3gg43; _gat=1"

Output

444t4#tb3gg43
view raw readme.md hosted with ❤ by GitHub