I'm trying to use a REST API as a datasource for a grid. It's been a nightmare. I've followed the Spotify example and managed to get that running. However ever other API I've tried simply will not work. The documentation on how to define the schemas is not at all easy to understand. There need to be many more examples of how to do this for other APIs especially ones that have multiple sections and levels.
I have tried to use this very simple REST API: https://jsonplaceholder.typicode.com/users
I created a schema for Address, Company, then User which includes the other fields and those previous schemas as arrays. Created a scheme Users which wraps User as an array and then UserResponse which wraps that.
When it's all said and done the grid will show the column names but no data is displayed. Instead I get this error:
System.Text.Json.JsonException: The JSON value could not be converted to ApiTester.Models.JsonPlaceHolder.UsersResponse. Path: $
Can anyone create a simple product consuming that API and displaying the results in a grid? I would love to see how it's done. In fact, I'd love to see several other examples of how people are defining and using API datasources.
I appreciate your reply but this doesn't address several issues. The JSON has multiple levels for the GEO, Address and Company items. How is this addressed? Again I tried to follow the structure of the tutorial but it's not working. I'm still getting the same error.
Here is the structure of the JSON I'm trying to consume:
"name": "Leanne Graham",
"street": "Kulas Light",
"suite": "Apt. 556",
"phone": "1-770-736-8031 x56442",
"catchPhrase": "Multi-layered client-server neural-net",
"bs": "harness real-time e-markets"
"name": "Ervin Howell",
"street": "Victor Plains",
"suite": "Suite 879",
"phone": "010-692-6593 x09125",
"catchPhrase": "Proactive didactic contingency",
"bs": "synergize scalable supply-chains"
Can you please create the schemas to handle that and display it?
if you paste the JSON data to https://json2csharp.com/ it will generate the basic structure
OK, I had done almost the same thing as you did. However, in the Address schema I have checked geo as an Array. Also in the User schema I have both Address and Company defined as arrays. Is this incorrect?
Based on the tutorial I also created two additional schemas:
items User - defined as an array
users Users This is what is used to create the Resource object
Is this incorrect? If so, why is it shown this way in the tutorial?
Yes, this is what I would do if I were coding the page by hand. This doesn't seem to help if using the Radzen tools.
Here is the application I've used to take the screenshots:
I'm not sure what else I can do to help. If you are looking for dedicated support the options are listed here:
I FINALLY got it to work. One major detail is that in the Resource where you are setting up the HTTP Status and schema you have to check the box to make it an Array.
I would highly suggest creating a few more tutorials using various APIs with varying levels of complexity. The current tutorial can lead people down a very dark rabbit hole as it did me.
I do appreciate your assistance as I was completely stuck.
I replied to the other thread you posted in.