- using System;
- using RestSharp;
- public class ApiService
- {
- public static void SendCallInformationApi(string ani, string nationalCode, string deviceNumber, string state)
- {
- try
- {
- string baseUrl = "http://192.168.0.133:8080/items/"; // Replace with the actual FastAPI server endpoint
- var client = new RestClient(baseUrl);
- var request = new RestRequest(Method.Get); // FastAPI expects a GET request in your provided code
- // Add query parameters to the request
- request.AddParameter("Ani", ani);
- request.AddParameter("NationalCode", nationalCode);
- request.AddParameter("DeviceNumber", deviceNumber);
- // Execute the API request synchronously
- RestResponse response = client.Execute(request);
- // If the response is not successful, handle it silently if no logging is required
- if (!response.IsSuccessStatusCode)
- {
- // Optionally throw an error or handle failure silently
- throw new Exception($"API call failed with status: {response.StatusCode}");
- }
- }
- catch (Exception)
- {
- // Silently catch errors or rethrow if needed
- // Example: throw;
- }
- }
- }
Recent Pastes