Emna Sallemi
Emna Sallemi

Reputation: 1

WSO2 Micro Integrator: 400 Bad Request Error While Calling API via <call> Mediator

I am using WSO2 Micro Integrator to call a native API that works successfully when tested directly via Postman, returning a 200 status code. However, when calling the same API through the Micro Integrator, I'm encountering "Bad Request 400" (Your browser sent an invalid request) error.

Here, the following error response:

<html>
<body>
    <h1>400 Bad Request</h1>
    Your browser sent an invalid request.
</body>
</html>

Here is the <inSequence> configuration I am using in my proxy service:

<inSequence>
    <enrich>
        <source clone="true" type="body"/>
        <target property="jwtToken" type="property"/>
    </enrich>
    <class name="TokenClassGen.TokenClassGen"/>
    <property expression="fn:concat('Bearer ', get-property('jwtToken'))" 
              name="Authorization" 
              scope="transport" 
              type="STRING"/>
    <call>
        <endpoint>
            <http method="get" uri-template="https://NATIVE-URL">
                <suspendOnFailure>
                    <initialDuration>-1</initialDuration>
                    <progressionFactor>-1</progressionFactor>
                    <maximumDuration>0</maximumDuration>
                </suspendOnFailure>
                <markForSuspension>
                    <retriesBeforeSuspension>0</retriesBeforeSuspension>
                </markForSuspension>
            </http>
        </endpoint>
    </call>
    <respond/>
</inSequence>

When I test the same request directly via Postman (with the same token and query), it works fine and returns a 200 status code.

  1. What could cause a 400 Bad Request error in this context when using WSO2 Micro Integrator?

  2. Could the issue be related to how query parameters are encoded or how the request is constructed?

  3. Are there specific configurations or debugging tips for ensuring compatibility with APIs that work in Postman but fail via WSO2 Micro Integrator?

Upvotes: 0

Views: 55

Answers (1)

Mohammed Khammeri
Mohammed Khammeri

Reputation: 11

Since it's a bad request.

  • Check Request Headers for starters: Content-type, Accept, etc. Otherwise add them explicitly.
  • Check for unseen extra whitespace between the JWT Token and the Bearer word, or at the end of the token. As a solution you can use trim function.
  • Log the Authorization header to verify that it matches what is sent via Postman.

Have a nice day.

Upvotes: 0

Related Questions