Spaces:
Sleeping
Sleeping
File size: 1,995 Bytes
6f32ae8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | using System;
using System.Net.Http;
using System.Net.Http.Json;
using System.Threading.Tasks;
using System.Collections.Generic;
class Program
{
static async Task Main()
{
var client = new HttpClient();
client.BaseAddress = new Uri("http://150.95.88.91:4100");
client.DefaultRequestHeaders.Add("x-system-id", "THS-LMS");
Console.WriteLine("Testing Loyalty API Connectivity...");
try
{
Console.WriteLine("\n1. Testing Active Rewards...");
var rewardsResponse = await client.GetAsync("/api/v1/rewards/active/THS-LMS");
Console.WriteLine($"Status: {rewardsResponse.StatusCode}");
if (rewardsResponse.IsSuccessStatusCode)
{
var content = await rewardsResponse.Content.ReadAsStringAsync();
Console.WriteLine($"Content: {content.Substring(0, Math.Min(100, content.Length))}...");
}
else
{
var error = await rewardsResponse.Content.ReadAsStringAsync();
Console.WriteLine($"Error: {error}");
}
Console.WriteLine("\n2. Testing Account Lookup (Test User)...");
// Using a dummy ID to see if we get a 404 or a connection error
var lookupResponse = await client.GetAsync("/api/v1/accounts/lookup/THS-LMS/test-user-id");
Console.WriteLine($"Status: {lookupResponse.StatusCode}");
if (lookupResponse.IsSuccessStatusCode)
{
var content = await lookupResponse.Content.ReadAsStringAsync();
Console.WriteLine($"Content: {content}");
}
else
{
var error = await lookupResponse.Content.ReadAsStringAsync();
Console.WriteLine($"Error: {error}");
}
}
catch (Exception ex)
{
Console.WriteLine($"\nCRITICAL CONNECTION ERROR: {ex.Message}");
}
}
}
|