API Connect

API Connect

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  400 Bad request when query parameter in request contains space

    Posted Mon July 08, 2024 12:21 PM
    Edited by Debasis Samal Tue July 09, 2024 03:41 AM

    Hi ,

       After V10  migration when consumer tested , noticed that when there is space in addresses?query=NC1Y 8CD , in case of v10  received 400 Bad request where as in V5 is working as expected with 200 OK.

    Flow is like APIC ----------- > Microservice------- > Backend.
    In case of V10 , microservice is throwing 

     HTTP response code 400 for 

    https:/Microservice Endpoint/addresses/?query=NC1Y%208CD

     where as in V5 

    200 OK

    'https:/Microsercvice Endpoint/addresses/?query=NC1Y%208CD

    Can anybody help us why in case of V10 Microservice is throwing 400 though  don't see any change in Microservice end.
    ------------------------------
    Debasis Samal
    ------------------------------



  • 2.  RE: 400 Bad request when query parameter in request contains space

    Posted Tue July 09, 2024 08:09 AM

    Hi Debasis,

    On your API's invoke policy, do you have either chunked-uploads enabled or is the property missing which the Gateway would default to enabled?  If so ensure the property is set to false and see if that makes a difference. Some backends don't support chunked uploads and can't properly parse out the request to get a valid request payload. 

    Regards,

    Steve Linn



    ------------------------------
    Steve Linn
    Senior Consulting I/T Specialist
    IBM
    ------------------------------



  • 3.  RE: 400 Bad request when query parameter in request contains space

    Posted Tue July 09, 2024 10:13 AM
    Hi Steve,

        I made it chunked-uploads: false which was true earlier , but  same error . 
    I made encode-plus-char: true too but error still persists

    Thanks,
    Debasis Samal





  • 4.  RE: 400 Bad request when query parameter in request contains space

    Posted Tue July 09, 2024 01:10 PM

    Hi Debasis,
    This is indeed puzzling. You note the backend urls are identical for both v5 and v10.  v5 never used chunked uploads which is why disabling them in v10 if there are problems is usually the first thing to try for errors like this.  The encode-plus-chars controls the plus character being sent to the backend.  The plus is one mechanism in the url of representing a space, but if you really wanted the backend to see a plus, then the plus with that option enabled will be sent as an encoded %2B which the backend should decode back to a plus.

    Are you saying that your v10 API does work when there is NOT a space in the query parameter value? If so I would suggest you open a PMR case on the issue as triaging it here in the forum isn't the right place.  You should provide a copy of your v5 and v10 API yaml file and DataPower debug logs showing the flow of the transaction.  If you have a physical / virtual DataPower appliance in v10, providing a packet capture in the PMR data of traffic to your backend (filtered by the host IP of the backend server), both from your v5 and v10 environments for this same transaction would be very useful for comparison purposes. If you can get the DataPower packet capture, please enable the TLS session keys option as well so your https traffic can be decrypted and the raw request data can be seen that is flowing in both cases.  If a v10 Kubernetes DataPower pod, packet captures are not done from DataPower but from the host machine which I've never done before.  L2 support will be able to assist you in getting these packet captures in the Kubernetes case.

    Best Regards,
    Steve Linn



    ------------------------------
    Steve Linn
    Senior Consulting I/T Specialist
    IBM
    ------------------------------



  • 5.  RE: 400 Bad request when query parameter in request contains space

    Posted Tue July 09, 2024 10:14 AM

    Hi Steve,

        I made it chunked-uploads: false which was true earlier , but  same error . 
    I made encode-plus-char: true too but error still persists
    Thanks,
    Debasis Samal


    ------------------------------
    Debasis Samal
    ------------------------------



  • 6.  RE: 400 Bad request when query parameter in request contains space

    Posted Fri August 02, 2024 05:20 PM

    The issue seems to be related to how the query parameters are being encoded in V10 compared to V5. Check if there's a difference in how the query string is being handled or any new validation rules in the V10 microservice that might be causing the 400 error. Apkdon.com



    ------------------------------
    Zohaib Arshad
    ------------------------------