Hello,
I am consuming one API which fetched the table data (Output response) based on the tableName(Input request)
"cmmn_fwdr_lkup table" and "DEVY_TYPE_lkup" are the table names(request param) being passed and gives response shown below.
Here the response structure is different for these two different input values.
how to manage the response structure is there any way to use this API only once based on changed input I dont want to make different API and respective response structures .
Thanks,
Shivani
You just call the API the way it is normally called. Change to do done in Service Studio -> Consume REST API . Here after you do the Test set the Body -> Response as "" and Click Finish.
Then you create a Sever action where you will invoke your API and post that result should be deserialise to respective structure.
Attached a small video of how this done.
I have created one structure with all attributes from the response (combined the attribute in one structure) and kept there json name same as json response
Then I am able to get the result as expected,
Hi Shivani,
If the possible structures are similar and known in advance, you can create a single structure to cover all the variations.
Otherwise, I'd suggest to receive the response as a plain text and implement your own logic to parse it.
I am doing something like above please let me know any other possible way or if I missed something
From the response json, I can understand you have dynamic list of attributes.
Could you check ardoJSON that has JSON_Listify action which can be used to convert the dynamic list of attributes into a list of key-value pairs.
check this article for detail implementation.
Could you please elaborate more How can I implement in my case, quite difficult to understand?
Thanks Mayank!
Regards,
I recommend separating the API call from the process of converting the result into the respective structure. After invoking the API, you should receive the result as plain text. Then, based on the input provided, for example, "DEVY_TYPE_lkup", deserialize the result into the corresponding structure.
No I have set response type as text/plain but Its giving error at the API call itself,
do you mean I should consume same API two times with different response structure ? Actually I have such 5 different cases,
please check below o/p if I set type test/plain