From b69567b03db5977aae69e3b24ad42c575dcf50b9 Mon Sep 17 00:00:00 2001 From: Santhosh-SF4792 Date: Sat, 6 Sep 2025 02:50:32 +0530 Subject: [PATCH 1/3] update the README.md file --- README.md | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c73bc44..2435552 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,74 @@ # fetch-data-using-webapi-treeview-xamarin -How to fetch data using Web API in Xamarin.Forms TreeView +This repository showcases how to populate the Syncfusion Xamarin.Forms TreeView control with hierarchical data fetched from a Web API. The included sample demonstrates making HTTP requests to retrieve JSON data, deserializing the response into a suitable object hierarchy, and binding the result to the TreeView. + +## Sample + +### XAML +```xaml + + + + + + + + + +``` + +### Helper +```csharp +internal class WebApiServices + { + public static string webApiUrl = "https://ej2services.syncfusion.com/production/web-services/api/Orders"; // Your Web Api here + + System.Net.Http.HttpClient client; + + public WebApiServices() + { + client = new System.Net.Http.HttpClient(); + } + + public async System.Threading.Tasks.Task> RefreshDataAsync() + { + var uri = new Uri(webApiUrl); + try + { + //Sends request to retrieve data from the web service for the specified Uri + var response = await client.GetAsync(uri); + + if (response.IsSuccessStatusCode) + { + var content = await response.Content.ReadAsStringAsync(); //Returns the response as JSON string + return JsonConvert.DeserializeObject>(content); //Converts JSON string to ObservableCollection + } + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine(@"ERROR {0}", ex.Message); + } + + return null; + } + } +``` + +## Requirements to run the demo +Visual Studio 2017 or Visual Studio for Mac. +Xamarin add-ons for Visual Studio (available via the Visual Studio installer). + +## Troubleshooting +### Path too long exception +If you are facing path too long exception when building this example project, close Visual Studio and rename the repository to short and build the project. + +## License + +Syncfusion® has no liability for any damage or consequence that may arise from using or viewing the samples. The samples are for demonstrative purposes. If you choose to use or access the samples, you agree to not hold Syncfusion® liable, in any form, for any damage related to use, for accessing, or viewing the samples. By accessing, viewing, or seeing the samples, you acknowledge and agree Syncfusion®'s samples will not allow you seek injunctive relief in any form for any claim related to the sample. If you do not agree to this, do not view, access, utilize, or otherwise do anything with Syncfusion®'s samples. \ No newline at end of file From fcca2fec5b607ee7ebc0357567b144b2113c6941 Mon Sep 17 00:00:00 2001 From: Santhosh-SF4792 Date: Sun, 7 Sep 2025 23:01:42 +0530 Subject: [PATCH 2/3] license correction commit --- README.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 2435552..14e9595 100644 --- a/README.md +++ b/README.md @@ -62,13 +62,9 @@ internal class WebApiServices ``` ## Requirements to run the demo -Visual Studio 2017 or Visual Studio for Mac. -Xamarin add-ons for Visual Studio (available via the Visual Studio installer). + +To run the demo, refer to [System Requirements for Xamarin](https://help.syncfusion.com/xamarin/system-requirements) ## Troubleshooting ### Path too long exception If you are facing path too long exception when building this example project, close Visual Studio and rename the repository to short and build the project. - -## License - -Syncfusion® has no liability for any damage or consequence that may arise from using or viewing the samples. The samples are for demonstrative purposes. If you choose to use or access the samples, you agree to not hold Syncfusion® liable, in any form, for any damage related to use, for accessing, or viewing the samples. By accessing, viewing, or seeing the samples, you acknowledge and agree Syncfusion®'s samples will not allow you seek injunctive relief in any form for any claim related to the sample. If you do not agree to this, do not view, access, utilize, or otherwise do anything with Syncfusion®'s samples. \ No newline at end of file From 854d3617f57ec16de2a927bec203a30d1ebdaae9 Mon Sep 17 00:00:00 2001 From: Santhosh-SF4792 Date: Mon, 8 Sep 2025 14:36:20 +0530 Subject: [PATCH 3/3] URL Correction commit --- README.md | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/README.md b/README.md index 14e9595..3b699be 100644 --- a/README.md +++ b/README.md @@ -3,32 +3,11 @@ This repository showcases how to populate the Syncfusion Xamarin.Forms TreeView ## Sample -### XAML -```xaml - - - - - - - - - -``` - ### Helper ```csharp internal class WebApiServices { - public static string webApiUrl = "https://ej2services.syncfusion.com/production/web-services/api/Orders"; // Your Web Api here + public static string webApiUrl = "Your URL"; // Your Web Api here System.Net.Http.HttpClient client;