1
votes

I have the following http request:

<http:request config-ref="FlowVarsHostAndPort" path="/rest/bpo/evento" method="POST" doc:name="Envia movimentacoes para Elaw Correspondente">
                    <http:request-builder>
                        <http:header headerName="Content-Type" value="application/json"/>
                    </http:request-builder>
                </http:request>

This service is inside a foreach, when it returns 200 its fine, but when it returns 404 it throws an exception an the flow stops, i need that when the service returns me a 404 i look at the payload and determine if it needs to keep executing the flow, how can i achieve it?

I tryed using the catch exception strategy but with no sucess.

ps: The service will return 404 when i'm looking for a resource that is not there, one example of response:

{
  "processo": "0009843-63.2016.8.13.0301",
  "mensagem": "Não foi possivel encontrar o processo"
}
1

1 Answers

4
votes

Before HTTP call, need to disable the behavior such that status code exception don't throw. In this case we can view the response from HTTP with status code and do logic whatever is required.

  <set-variable variableName="http.disable.status.code.exception.check" value="true" /> 

In other way around

If you want to limit only for 404. Say to HTTP 404 is one of the success response by using SuccessStatusCode validator.

 <http:request config-ref="" path="/rest/bpo/evento" method="POST" doc:name="Envia movimentacoes para Elaw Correspondente">
                <http:request-builder>
                <http:header headerName="Content-Type" value="application/json"/>
                </http:request-builder>
            <http:success-status-code-validator values="200,404"/>
  </http:request>

Reference:https://docs.mulesoft.com/mule-user-guide/v/3.7/http-request-connector. Check HTTP Response validation part in this reference url.