REST Request

Dear Masters, will you help how to do REST request in Radzen for this command;

JSON request
curl -k -X POST -L https://172.16.25.191/api -d
'{"apirequest":{"auth":{"username":"api_user","password":"secret"},
"action":"query","item":"api_alarm"}}'

JSON response
{"apiresponse":{"status_code":200,"status_text":"Success","result":[{
"item":{"name":"api_alarm","type":"view","returns":"recordset",
"columns":[
{"column":{"name":"alarm_type_num","type":"integer"}},
{"column":{"name":"alarm_description","type":"char(20)"}},
{"column":{"name":"auto_or_manual_can","type":"char(1)"}},
{"column":{"name":"priority","type":"integer"}}]}}]}}

Thank you,
Fauzi

Hi @fsetianto,

You can try creating a REST data source following this tutorial.

Hi @korchev, thanks for your prompt reply. I had tried to follow the tutorial with no luck.

Will you guide me more on this?

Regards,
Fauzi

@fsetianto, what step in the tutorial were you unable to follow? Did you get an error message and if so what was it?

Hi @mumfie, it was not the step on tutorial. I tried to make data source for our API server that only allow HTTP POST request. When I want to Invoke Data Source Method, there is no data resource appear on selection. I thought it must be GET request so the data resource can be appeared on selection as showed in tutorial.

So, please enlighten me how to do POST request and bind to any component like datagrid.

Thank you...

@fsetianto,
I have created a simplified example to access an external api at https://dotnetcore-todo-webapi.herokuapp.com/v1/todos

The datasource demonstrates POST, GET and DELETE operations but could be extended for others.
https://github.com/mumfie2003/testTodoApiPost/blob/main/meta/data/ToDoBackend.json
This is an angular version but blazor should be similar.
The Add Todo button uses POST and the list is populated by Get
There is a video demonstrating it working in the same repo.
https://github.com/mumfie2003/testTodoApiPost/blob/main/radzen-api-post.gif

And another example using the Radzen Crud pages wizard against the datasource
https://github.com/mumfie2003/testTodoApiPost/blob/main/radzen-crud-pages-api.gif

@mumfie, thank you for your kindness, it is so helpful for me.

Thanks again @mumfie...

1 Like