如何通过In Flow mediator在wso2 apim 2.6.0中将头参数添加到rest API中

问题描述 投票:1回答:1

我在wso2 apim 2.6.0上有Rest API,它有json输入和输出。并且有Get资源。我想为它添加标头参数。所以我需要In flow mediator。

我使用这个中介但它不起作用。

<?xml version="1.0" encoding="UTF-8"?>
<sequence name="newUser" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
    <header name="caller-token" scope="transport" value="234"/>
    <header name="Content-Type" scope="transport" value="application/json"/>
    <header name="Authorization" scope="transport" value="Bearer dd"/>
    <header name="Access-Control-Allow-Origin" scope="transport" value="https://onlineapi.agah.com/api/v1/"/>
    <property name="messageType" scope="axis2" type="STRING" value="application/json"/>
    <log level="full"/>
</sequence>

在商店中调用它后我得到此错误:(400)错误:未找到响应标头:content-type:application / octet-stream

header wso2 wso2-am wso2carbon mediator
1个回答
0
投票

这必须是CORS问题。您需要在CORS规则中启用自定义标头。将自定义标题添加到CORS中的api-manager.xml部分。这会影响所有API。如果您只想为特定API添加此项,则可以在API本身中对其进行配置。

Rer:https://docs.wso2.com/display/AM260/Enabling+CORS+for+APIs

© www.soinside.com 2019 - 2024. All rights reserved.