how to define REST API response
Application Type
Mobile

Hi everyone

I have question about convert/bind response using Rest API ( example : i try to consume this API the data is defined to integer and i try to convert using other api to define each data " from_divisi_id = 1" become "from_divisi_id = "IT" )

the response converted to this : 

do i need to create  output parameter each structure or anyone have a good option to solve this ? please let me know 

Best Regards,

Yansen

TemasTicketingSystemApps_v162.oml

Hello,

The way I see it, you have 2 options:

  1. Pre-fetch all companies, departments, etc. and store them in the database. Then, after calling the "PostGetTicketById" method, you'd need to query the database to get the record's names. This approach has many disavantages, like having to query the DB multiple times for each record returned by the API and having to make sure you always have the complete list of companies, departments, etc. in your database.
  2. Request a change to the REST API so that it also returns the record's names, and not only their IDs. This is probably your best option.

Hi mr @Aurelio Junior 

thanks for your response, i try not to store it to outsystems database, so can you help me explain more your second option sir ? 


You'd need to talk to whoever is responsible for building this API and ask them to add fields like "from_company_name", "from_department_name", etc. to the response.

Other than that, your only options are to store the records in the database as I described above, or to call the other APIs to fetch the individual records and get their names. None of those 2 is a very good option.

i got second api to define each response, it is possible using other api to define it in outsystems?

I'm sorry, I don't understand your question. Could you please elaborate?

i have api to describe each integer, i mean it is possible use it in outsystems? 


Yes it is. But as I said, this is not a very good option. It would mean that for every integer you want to describe, you would have to call another API. For instance, in your case I see IDs for company, deparment, division, branch and others. That's already 4 separate API calls just to get the record's names. Doing it this way would most likely result in peformance issues in your application.

thisHello Yosua,

You can handle the response of your API on an OnAFterResponse event of your API.

This event triggers when you receive your call and you have access to the Response body where you can change the values of the response. 

For more information please read this post.

Hope it helps!

Paulo Rosário

Hi Mr @Paulo Rosário 👨🏽‍🚀 

Thanks for your response i will try ur suggestion 


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