TEXT 72
Untitled Guest on 25th December 2024 07:07:42 AM
  1. using System;
  2. using System.Threading.Tasks;
  3. using RestSharp;
  4.  
  5. public class ApiClient
  6. {
  7.     public static async Task SendCallInformationApi(string ani, string nationalCode, string deviceNumber, string state)
  8.     {
  9.         try
  10.         {
  11.             string url = "http://192.168.0.133:8080/items/"; // Ensure this matches your FastAPI server and endpoint
  12.  
  13.             var client = new RestClient(url);
  14.             var request = new RestRequest(Method.Get);
  15.  
  16.             // Add query parameters
  17.             request.AddParameter("Ani", ani);
  18.             request.AddParameter("NationalCode", nationalCode);
  19.             request.AddParameter("DeviceNumber", deviceNumber);
  20.  
  21.             RestResponse response = await client.ExecuteAsync(request);
  22.  
  23.             if (response.IsSuccessStatusCode)
  24.             {
  25.                 Console.WriteLine("API call succeeded.");
  26.                 Console.WriteLine("Response: " + response.Content);
  27.             }
  28.             else
  29.             {
  30.                 Console.WriteLine("API call failed with status: " + response.StatusCode);
  31.             }
  32.         }
  33.         catch (Exception ex)
  34.         {
  35.             Console.WriteLine("Error occurred: " + ex.Message);
  36.         }
  37.     }
  38. }

Hightechrobo bin is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.