I have a requirement on my REST API where I might set some attributes before APIKit if some condition is met (because we have a logger which must write this information).
Following this solution, I created the script below to set Attribute object inside Transform component.
%dw 2.0
output application/json
---
(
(attributes
- "headers"
- "maskedRequestPath")
++
({
headers: attributes.headers
++
{
xpto: 123
}
})
)
as Object {
class: "org.mule.extension.http.api.HttpRequestAttributes"
}
However, I am getting org.mule.weave.v2.el.ByteArrayBasedCursorStreamProvider cannot be cast to org.mule.extension.http.api.HttpRequestAttributes
error.
Is there a way where I can successfully set these values before APIKit Router?
I am using APIKit v1.6.1, with 4.3.0 runtime.
You should use output application/java
in order to create an HttpAttributes