- using System;
- using System.Threading.Tasks;
- using RestSharp;
- public class ApiClient
- {
- public static async Task SendCallInformationApi(string ani, string nationalCode, string deviceNumber, string state)
- {
- try
- {
- string url = "http://192.168.0.133:8080/items/"; // Ensure this matches your FastAPI server and endpoint
- var client = new RestClient(url);
- var request = new RestRequest(Method.Get);
- // Add query parameters
- request.AddParameter("Ani", ani);
- request.AddParameter("NationalCode", nationalCode);
- request.AddParameter("DeviceNumber", deviceNumber);
- RestResponse response = await client.ExecuteAsync(request);
- if (response.IsSuccessStatusCode)
- {
- Console.WriteLine("API call succeeded.");
- Console.WriteLine("Response: " + response.Content);
- }
- else
- {
- Console.WriteLine("API call failed with status: " + response.StatusCode);
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine("Error occurred: " + ex.Message);
- }
- }
- }
Recent Pastes