anypoint studio - MuleSoft http request connector header in literal mode issue - Stack Overflow

Hello Mule Developers,I noticed that in the MuleSoft HTTP Request Connector, the header in literal mod

Hello Mule Developers,

I noticed that in the MuleSoft HTTP Request Connector, the header in literal mode requires quotation marks (""). For example, it needs to be written as "${restendpoint.project.tokenName}" instead of ${restendpoint.project.tokenName}.

Is this a bug in the IDE, or is it the expected behavior?

e.g. this is without qutation, for Http request connector header in literal mode ${restendpoint.project.tokenName} , it has red color warning in IDE tool

this is with qutation, for Http request connector header in literal mode "${restendpoint.project.tokenName}" , it shows green in IDE tool

Hello Mule Developers,

I noticed that in the MuleSoft HTTP Request Connector, the header in literal mode requires quotation marks (""). For example, it needs to be written as "${restendpoint.project.tokenName}" instead of ${restendpoint.project.tokenName}.

Is this a bug in the IDE, or is it the expected behavior?

e.g. this is without qutation, for Http request connector header in literal mode ${restendpoint.project.tokenName} , it has red color warning in IDE tool

this is with qutation, for Http request connector header in literal mode "${restendpoint.project.tokenName}" , it shows green in IDE tool

Share Improve this question asked Mar 24 at 12:28 stewchickenstewchicken 5411 gold badge9 silver badges26 bronze badges 2
  • 1 What is the result of execution in both cases? The header is correct in both or only in one? – aled Commented Mar 24 at 20:11
  • wihtout quotation , it could not run, with syntaxt error, here is xml code <http:headers ><![CDATA[#[output application/java --- { ${restendpoint.project.tokenName} : ${secure::restendpoint.project.tokenValue} }]]]></http:headers> </http:request> – stewchicken Commented Mar 25 at 7:00
Add a comment  | 

1 Answer 1

Reset to default 1

The error is correct because setting the headers with properties is invalid syntax. The reason is that headers are configured in a DataWeave script inside the XML:

<http:request method="GET" doc:name="Request" config-ref="HTTP_Request_configuration" path="/">
    <http:headers ><![CDATA[
        #[output application/java
        ---
        {
            "${name}" : "${value}"
        }
    ]]]>
    </http:headers>
</http:request>

If we remove the quotes it would be invalid DataWeave syntax. Having said that, property substitution in DataWeave is not done with the property placeholders (${...}) but with the p() function. It kind of works as a side effect of the DataWeave being inside the XML and property placeholders are replaced at the XML level. If the script were moved to its own file it would not work as it is. Or if in the future Mule doesn't replace placeholders inside DataWeave scripts it could fail though it is a theoretical scenario.

The correct syntax for the script should be as follows:

#[output application/java
---
{
    p("name") : p("value")
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744252058a4565216.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信