在将JSON有效负载发布到POST Rest API时获取响应404

时间:2017-07-19 02:34:09

标签: json post mule payload mule-esb

我试图将MSON有效负载发布到MuleESB中的公共POST Rest API但我收到此错误:

org.mule.module.http.internal.request.ResponseValidatorException:响应代码404映射为失败。

我可以通过Postman Chrome App使用JSON正文调用API,但不能通过Postman Desktop App或MuleESB调用。在过去的两天里我一直在谷歌,但仍然不知道我错过了什么。如果你有一个线索导致这种情况无法发挥作用,请赐教。

这是JSON有效负载:

{
  "username": "dummy",
  "email": "dummy@dummy.com",
  "firstName": "dummy",
  "lastName": "dummy"
}

这是我的MuleESB代码的片段(我使用的是3.8.3):

        <http:request-config name="HTTP_Request_Configuration" host="api.domain.com" port="443" doc:name="HTTP Request Configuration" protocol="HTTPS" responseTimeout="180000" tlsContext-ref="TLS_TrustStore"/>
        <tls:context name="TLS_TrustStore" doc:name="TLS">
            <tls:trust-store path="cacerts.jks" password="pwd"/>
        </tls:context>
        ...
        <dw:transform-message doc:name="Transform Message" metadata:id="c77537ba-aaf3-4497-9f09-06792d1f7556">
        <dw:input-payload mimeType="application/java"/>
        <dw:input-variable doc:sample="sample_data\UserDefined.dwl" variableName="userData"/>
        <dw:set-payload><![CDATA[%dw 1.0
%output application/json
---
{
    username: flowVars.username as :string,
    email: flowVars.email as :string,
    firstName: flowVars.firstName as :string,
    lastName: flowVars.lastName as :string
}]]></dw:set-payload>
        </dw:transform-message>
        <logger message="payload:#[payload]" level="INFO" doc:name="Logger"/>        
        <set-property propertyName="Content-Type" value="application/json" encoding="UTF-8" mimeType="application/json" doc:name="Property"/>        
        <until-successful maxRetries="3" doc:name="Until Successful" synchronous="true">
            <http:request config-ref="HTTP_Request_Configuration" path="/api/1/users" method="POST" doc:name="HTTP">
                <http:request-builder>
                    <http:header headerName="Authorization" value="abcdefg"/>
                </http:request-builder>
            </http:request>
        </until-successful>

1 个答案:

答案 0 :(得分:-1)