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.  JSON Array request in API Connect

    Posted Sat July 15, 2023 04:54 AM
    Edited by Anusha Pudari Mon July 17, 2023 01:03 AM
    Hi All,
    I am experiencing an issue when using a JSON Array request in API Connect. Below is a description of the problem.
    I have developed an API with a backend URL configured in the invoke policy. However, when testing the API using the provided request, I expected a successful response from the backend, but instead, I received an message stating "Incorrect JSON Format " from the backend.
     
    Request:
    {
        "UniqueID""xxxxxx",
        "Type""xx",
        "Persons": [
            {
                "PersonType""x",
                "DetailsList": [
                    {
                        "PersonalDetails": {
                            "FirstName""xxxxxxx",
                            "LastName""xxxxxxxx"
                        },
                        "AdditionalDetails": {
                            "Education""xxxxxxx",
                            "BankList": [
                                {
                                    "Bankname""xxxx",
                                    "BankBranch""xxxx"
                                },
                                {
                                    "Bankname""xxxx",
                                    "BankBranch""xxxx"
                                }
                            ]
                        },
                        "Address": {
                            "permanentAddress""xxxx"
                        }
                    }
                ]
            }
        ]
    }
     
    Response:
     
    {
        "status""200",
        "MessageDesc""Incorrect JSON format"
    }
    However, when I directly tested the backend with the same request, I received the following response:
     
    Backend Response:
     
    {
        "status""200",
        "result": [
            {
                "MessageDesc""Successfully inserted"
            }
        ]
    }
     
    Please note that the request data is stored in the context variable, which reflects the actual content I used to hit the API.
    The backend URL configured in DataPower works fine as expected, and when the DataPower URL is configured in the invoke policy, it also works fine. However, when I configure the direct backend URL in API Connect, it is not functioning as expected.



    ------------------------------
    Anusha Pudari
    ------------------------------



  • 2.  RE: JSON Array request in API Connect

    Posted Mon July 17, 2023 08:47 AM

    Hi Anysha,

    Are there any other policies in your API prior to the invoke policy?  Can you do a packet capture from your DataPower appliance to the back, with ssl session keys if a https connection?

    Best Regards,

    Steve Linn



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



  • 3.  RE: JSON Array request in API Connect

    Posted Mon July 17, 2023 11:46 AM
    Edited by Anusha Pudari Mon July 17, 2023 12:12 PM

    Hi Steve,

    There is only one policy (i.e., the log policy) in my API prior to the invoke policy. Please find the attached packet capture and SSL session key.



    ------------------------------
    Anusha Pudari
    ------------------------------

    Attachment(s)

    zip
    capture.zip   398 KB 1 version
    log
    sslkeyfile.log   5 KB 1 version


  • 4.  RE: JSON Array request in API Connect

    Posted Mon July 17, 2023 04:44 PM

    Hi Anusha,
    I used Wireshark on your packet capture and searching for the text POST or GET I'm not finding anything that isn't DataPower specific (webgui, etc).  What is your url to your API?  Assuming I can't find that in the capture, please add a filter of host w.x.y.z where w.x.y.z is the IP of your invoke target-url so we'll be able to only capture traffic from DataPower to your backend and will not capture internal webgui traffic.
    Best Regards,
    Steve Linn



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



  • 5.  RE: JSON Array request in API Connect

    Posted Tue July 18, 2023 06:02 AM
      |   view attached

    Hi Steve,

    Please find the attached packet capture without ssl session keys.

    Destination IP: 10.69.34.104



    ------------------------------
    Anusha Pudari
    ------------------------------

    Attachment(s)

    zip
    capture (7) (1).zip   739 KB 1 version


  • 6.  RE: JSON Array request in API Connect

    Posted Wed July 19, 2023 06:23 AM

    Hi @Steve Linn

    Could you please check the packet capture that I shared with you in my previous post.



    ------------------------------
    Anusha Pudari
    ------------------------------



  • 7.  RE: JSON Array request in API Connect

    Posted Wed July 19, 2023 02:36 PM

    Hi Anusha,

    Sorry but I've having issues posting an answer.  Trying this out as a simple test

    Best Regards,
    Steve




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



  • 8.  RE: JSON Array request in API Connect

    Posted Wed July 19, 2023 02:42 PM

    Hi Anusha,
    So very strange.  I keep getting "no permission to post to this site", but apparently it must have something to do with the text I'm attempting to post.

    Looking at the packet capture, your JSON is well formed.  I see that the message is being sent using chunked encoding.   Does your backend accept chunked encoding? It consists of some length bytes that precede and follow the actual payload when using chunked encoding.  There is a checkbox toward the bottom of the invoke policy properties that by default is enabled for allowing chunked uploads.  Please disable it and see if that resolves your issue.

    Best Regards,
    Steve Linn



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



  • 9.  RE: JSON Array request in API Connect

    Posted Thu July 20, 2023 02:32 AM

    Hi Steve,

    Thank you for your reply; it has been very helpful. I resolved my issue by disabling the "allowing chunked uploads" in invoke policy.



    ------------------------------
    Anusha Pudari
    ------------------------------