cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping a rest API response in Build Apps

08-01-2023 4:42 AM
souvikroy Participant
5599 views 9 comments
SAP Managed Tags
Subscribe

I am consuming a REST API in Build App and need to map few fields from data collection and as well as msgs.count from collections collection as shown in below images.

I have added below code in Response mapper to map fields from the data collection and created an entity.

{ records: response.data.data , driverCode: response.status }


Is it possible to map the msgs.count from collections collection as well in the same entity along with other fields from data collection from the rest API?

Accepted Solutions (0)

Answers (5)

Answers (5)

Dan_Wroblewski
Developer Advocate
Developer Advocate

To manipulate in the data resource, you would take your formula you used (and Marc rightly said was unnecessary above) but now use it and add functions to manipulate the data, now that you want to manipulate here.

Just as an example, I took Northwind and set the retrieve to return the first record.

Then I added this to the response mapper ...

{ records: PICK_KEYS(response.data,["CustomerID", "City"]), driverCode: response.status }

... so that it returned the same record but with fewer fields.

You can do whatever you need in the formula.

vikas_992001
Explorer
0 Likes

Hi Souvik,

Please see my response in this one. Hope this will work for you.

https://answers.sap.com/answers/13938600/view.html

Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Likes

I am assuming this question is related to the other question you entered.

So you could:

  • Do the data manipulation here, in the data resource.
  • Do the the data manipulation in a set data variable flow function to reset the data variable.
  • Do the data manipulation before the binding.

It depends which data you will need and when.

souvikroy
Participant
0 Likes

Hi daniel.wroblewski I was able to manipulate in a set variable flow function . Can you please guide me, how we can map/manipulate in the data resource itself.

Note: The API is a standard API and I will not be able to manipulate the response layout of the API.

MarcHuber
Product and Topic Expert
Product and Topic Expert
0 Likes

With { records: response.data.data , driverCode: response.status } you are filtering the results for the data entity of your api call. Just remove the response mapper. Afterwards you will have access to also to the collections entity.

Best regards,

Marc

souvikroy
Participant
0 Likes

Hi Marc, Thanks for your reply. The reason I added the response mapper, so that I can bind the response with the list report correctly otherwise, I will not be able to bind the response to a data variable to repeat it as list.

Ben_Samuel
Explorer
0 Likes

Thanks Marc, 

it works for me and i can bind it correctly

souvikroy
Participant
0 Likes

Hi Daniel,

Yes,it comes from same API call json response.

I need to display a list report with the below columns. I also added their mapping.

I will be using Row component and would like to repeat the data rows on the data variable for display.