184
Views
5
Comments
REST API give success response but not returning output

Hi All, 

So i've been using consume REST API post method, This API is used to send notification message to Whatsapp with this JSON structure:


{

    "list_phone_no": [

        "08xxxxxxxx"

    ],

    "type": "template",

    "template": {

        "namespace": "9df851b3_7bf1_406d_b970_047b6a580e02",

        "language": {

            "policy": "deterministic",

            "code": "id"

        },

        "name": "wa_whatsapp2023092101",

        "components": [

            {

                "type": "body",

                "parameters": [

                    {

                        "type": "text",

                        "text": "TEXT_NO.1"

                    },

                    {

                        "type": "text",

                        "text": "TEXT_NO.2" 

                    }

                ]

            }

        ]

    }

}



Whenever i testing using JSON structure on the service studio it works fine and i get the notification on my whatsapp.

but when i make it on action client logic using the created structures on the request.

i dont get the message but the transaction is success

and also on service center the API runs well.

i also tried to not using List on the structures, but it returns '40 bad service' error.

Does anyone has same experience or know how to find what i missing? 

Thank you in advance. 


UserImage.jpg
Christian Kyle Floresta

Hi Revan,


My initial assumption is that the structure of the response body for the API maybe different from what is being sent from the API. 

Since Outsystems will try to parse the response based on the structure you have set, maybe there is a problem with how its currently set that's why Outsystems cannot parse it?

Another suggestion that can help is debugging by adding an OnAfterResponse to it like the one here in the image below.

After adding an OnAfterResponse, another Action will be created which automatically runs whenever the API you are calling sends its response. 

You can place a Breakpoint here then take a look at the value of Response.ResponseText since its the raw text response from the API. 

UserImage.jpg
Revan Sentosa

Halo kyle,

thanks for the response, i already added the onafterresponse and debbugged it, but i saw nothing is wrong


UserImage.jpg
Alexandre Yip

Hi Revan Sentosa, 

When that error happens after the after response callback is something related to the output structure. 

Check that output structure. 

Also in integrations for that eSpace add the full log and check what is being logged. 

Hope that it helps you 

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Yes, that's always the #1 thing to do in situations like this, check the content of what is sent and received, by increasing the logging level of the API and check, in the Integration Log, what has been sent.

2020-11-05 04-47-48
Nghia Hoang

Hi Revan, 

I saw that you have this assignment:

Please try not do that. Instead you should use ListAppend Action to append a Phone number to the List, something similar this : 

Kind regards,

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.