尝试连接到REST API时收到有效负载错误

用户名

我希望调用内部REST API,并将有效负载传递回Mule 3.7.3。该请求仅是URL,没有任何正文,但是我收到了诸如nullPayload之类的有效载荷错误。

我怎样才能使它正常工作?

我正在使用此公共API https://apisandbox.openbankproject.com/obp/v2.0.0/banks对其进行测试

我模拟的代码在这里:

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.7.3"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd">
    <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
    <http:request-config name="HTTP_Request" host="https://apisandbox.openbankproject.com" port="443" basePath="/obp/v2.0.0" doc:name="HTTP Request Configuration"/>
    <flow name="account-balance-flow">
        <http:listener config-ref="HTTP_Listener_Configuration" path="/" allowedMethods="GET" doc:name="HTTP"/>
        <set-payload value="#['{}']" doc:name="Set Payload"/>
        <http:request config-ref="HTTP_Request" path="/banks" method="GET" doc:name="HTTP"/>
        <logger message="#[message.payload]" level="INFO" doc:name="Logger"/>
    </flow>
</mule>
瑞安·卡特(Ryan Carter)

主机不应包含URL。它应该只是主机,并且HTTPS协议是分别指定的。另外,无需为GET请求设置有效负载。有效的更新代码:

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.7.3"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd">
     <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
    <http:request-config name="HTTP_Request" protocol="HTTPS" host="apisandbox.openbankproject.com" port="443" basePath="/obp/v2.0.0" doc:name="HTTP Request Configuration"/>
    <flow name="account-balance-flow">
        <http:listener config-ref="HTTP_Listener_Configuration" path="/" allowedMethods="GET" doc:name="HTTP"/>
        <http:request config-ref="HTTP_Request" path="/banks" method="GET" doc:name="HTTP"/>
        <logger message="#[message.payload]" level="INFO" doc:name="Logger"/>
    </flow>
</mule>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

对 Bitbucket Server 进行 REST API 调用并尝试传递 JSON 有效负载会导致错误

从有效负载创建时,Django Rest Framework Not Null 错误

如何计算Rest API有效负载大小?

REST API 中 PUT 与 POST 的有效负载

从ANGULAR连接到REST API

尝试连接到Lighthouse API时出现401错误

Kafka TestContainer 尝试连接到错误的攻击

尝试连接到Networkshare时句柄无效

尝试连接到RabbitMQ时出现IncompatibleProtocolError

尝试连接到 vTiger 时凭据无效

尝试从 quarkus 连接到 keycloak 时出错

尝试连接到蓝牙服务器时连接被拒绝

尝试连接到服务器时,Sshutle连接被拒绝

尝试连接到Kubernetes中的服务时连接被拒绝

当我尝试从连接到 TFS 2015 的 Visual Studio 2017 触发构建时收到以下错误

尝试使用SIP用户连接到Asterisk时收到“错误密码”

无法使用或连接到Mailmans REST API

连接到REST API的DialogFlow实现

如何从Swift连接到Gmail REST API

尝试连接到数据库时遇到错误 08001

尝试远程连接到 InfluxDB 时出现 502 网关错误

尝试连接到SQL Server 2014时出现SSL错误

尝试从Java连接到Https URL时出现401错误

尝试连接到 Team Foundation Server 时出现错误 500

尝试连接到 TFSAPI 时出现错误 401

尝试连接到有状态集Mongodb Kubernetes部署时没有连接错误

ALM使用JSON有效负载(REST API)创建新的测试运行

如何在传输过程中保护REST API有效负载?

如何在Java中将请求有效负载发送到REST API?