0

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.

mhery
  • 2,097
  • 4
  • 26
  • 35

1 Answers1

3

You should use output application/java in order to create an HttpAttributes

machaval
  • 4,969
  • 14
  • 20
  • hello @machaval, thanks for your answer, it worked! now I have a more complex requisite, and asked another question: https://stackoverflow.com/questions/73120074/errors-while-creating-serializablelazyvalue-by-reflection-when-trying-to-set-s glad if u could help too! – mhery Jul 26 '22 at 08:31