2024 May 03 2:39 PM - edited 2024 May 03 4:19 PM
Hello MDK SAP Community,
I am seeking assistance with displaying the sub-properties of a REST API response within the fields of an Object Table, within e.g. the "Title" and "Subhead" fields.
I am working with the following API endpoint: https://dummyjson.com/products
The JSON response I am receiving is structured as follows:
{ "products": [ { "id": 7, "title": "Samsung Galaxy Book", "description": "Samsung Galaxy Book S (2020) Laptop With Intel Lakefield Chip, 8GB of RAM Launched", "price": 1499, "discountPercentage": 4.15, "rating": 4.25 }, { "id": 8, "title": "Microsoft Surface Laptop 4", "description": "Style and speed. Stand out on HD video calls backed by Studio Mics. Capture ideas on the vibrant touchscreen.", "price": 1499, "discountPercentage": 10.23, "rating": 4.43 }, // Additional product objects... ] }
My goal is to extract e.g. the "id" and "title" properties from each product and display them in the "Title" and "Subhead" fields (just as example), respectively, of an Object Table.
I have attempted the following bindings, but none have worked:
I can confirm that the API call is successful, as I am receiving a 200 OK status along with the expected response data.
For single product calls such as "https://dummyjson.com/products/1", the mapping of "Title": {id} and "Subhead": {title} works well. However, the issue presents itself when attempting to list multiple products.
Could someone please guide me on the correct way to bind these (sub)properties within an Object Table for a list of products?
Thank you for your time and assistance.
Khaled El Ghali
Request clarification before answering.
The binding is based on the structure of the return JSON. In the example you gave, the properties are all just top level properties on the product object so you can just bind to the property name.
"ObjectCell": {
"Title": "{title}",
"Subhead": "{category}",
"Footnote": "{brand}",
"DisplayDescriptionInMobile": true,
"StatusText": "{price}",
"PreserveIconStackSpacing": false,
"AccessoryType": "None"
}
When using a REST service, it is important to understand both the path for the service endpoint as well as the output path. Depending on how you defined the URL for the destination you may or may not need a path. For the output path, in this case for an Object Table it is expecting an array of objects. For the products call the response includes the array under the products property so the output path needs to be set to /products.
Here is how I defined my target for the object table to display the products list. Note: I use a path as well because my destination in Mobile Services is set to just the root https://dummyjson.com
"Target": {
"Service": "/SCN_00027/Services/DummyJSON.service",
"Path": "/products",
"OutputPath": "/products",
"RequestProperties": {
"Method": "GET"
}
}
My guess is your Target does not include the output path so the object table does not know where the array is to render.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @bill_froelich ,
your solution worked perfectly for the issue I was facing.
Thank you so much for your support and for being part of the SAP Community! Best regards,
Khaled
User | Count |
---|---|
86 | |
11 | |
8 | |
8 | |
6 | |
6 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.