Rest API issues

Hi all,

Have a whale of a time trying to get my first REST service set up.
I've moved away from ASPRunner (which was so very easy to set up consuming REST api) and can't get my head around the RadZen way or the short tutorial on docs site.

Scenario: I enter vehicle Registration plate into a field and use this as a parameter in the query string to return the following Json result:
"idh":
{
"plate":"JODIZ",
"query_type":"IDH",
"date":"20220504",
"created":1651609029,
"response_version":2,
"keep":0,
"motochek_transaction_id":344065691,
"header":
{
"not_found":"",
"not_assigned":false
},
"vehicle":
{
"year_of_manufacture":"2008",
"make":"AUDI",
"model":"A3",
"submodel":"",
"body_style":"HA",
"vehicle_type":"07",
"vin":"WAUZZZ8P78A203098",
"chassis":"WAUZZZ8P78A203098",
"engine_no":"BZB",
"cc_rating":1790,
"main_colour":"Black",
"second_colour":"",
"reported_stolen":"N",
"country_of_origin":"GER",
"assembly_type":"1",
"gross_vehicle_mass":1735,
"no_of_seats":5,
"fuel_type":"01",
"alternative_fuel_type":"",
"registration_status":"A",
"previous_country_of_registration":"JPN",
"year_of_first_registration_overseas":2008,
"month_of_first_registration_overseas":9,
"plate":"JODIZ"
},
"created_sto":1651609029
},
"hidh":null,
"ioh":null,
"hioh":null,
"irh":null,
"hirh":null
}
}

For the life of me, I cannot get the schema set up to work.
For the life of me I cannot figure out how to get my query string set up to accept the "plate" parameter for the lookup!

Please help....

What seems to be the problem? You need to define a Schema for your model. Nested complex properties need a new schema (e.g. idh, header, vehicle). Here is an example for some of those:

ApiResult is the "root" model that will be used as the response of your API (more a bit later). Notice it has an idh property which is of type IDH which is another schema. IDH itself has plate and response_version as well as header and vehicle which are complex objects hence need a schema of their own - Header and Vehicle. You can specify only the properties you would use in your application.

You define a query parameter of your API method (specified via the In dropdown)

Also notice that the Response is set to be of ApiResult schema which we defined earlier.

We have defined a getPlate method which performs a HTTP GET request to /plates?plate=<value> and returns an instance of the ApiResult schema on success (HTTP Status 200).

Find attached a sample Radzen Angular application which I created for taking the screenshots.
rest.zip (103.9 KB)

1 Like

Thank you. Seeing the schema in context made it "click". Appreciated.

Hi,
I'm learning my way around Radzen, I'm sorry.
Following instructions on docs:
Step3 Create new page, point 2 create page property - cannot find where to do this.

You can check the Properties article from the Fundamentals section. It shows how to work with properties.

1 Like

Thanks. now I have a slightly different issue - default result from api is xml.
the query url should be: ?plate=&basic=1&f=json
how can I append the &basic=1&f=json to the query string?

By defining additional query parameters to your operation (check my second screenshot).