I’m working with a C# Web API and React TypeScript frontend. When I send a GUID from my frontend to the backend endpoint, the backend always gets an empty GUID (all zeros) instead of the actual value I’m sending.
Backend Controller:
[Route("FetchByUser")]
[HttpGet("{userId}")]
public async Task<ActionResult<List<Appointment>>> FetchByUser(Guid userId)
{
Console.WriteLine(userId); // Shows: 00000000-0000-0000-0000-000000000000
// rest of logic here
}
Frontend Service Function:
export const fetchAppointmentsByUser = async (userId: string) => {
const endpoint = "http://localhost:5032/appointments/FetchByUser?userId=" + userId;
console.log(endpoint); // URL looks correct in console
// API call logic
}
Component Usage:
useEffect(() => {
setAppointments([]);
const loadAppointments = async () => {
const testUserId = "A1B2C3D4-E5F6-7890-ABCD-EF1234567890";
const result = await fetchAppointmentsByUser(testUserId);
setAppointments(result);
}
loadAppointments();
}, []);
The URL in the browser console shows the correct GUID, but the backend parameter is always empty. No errors are thrown. What could be causing this issue?