Skip to main content

Hi! Getting error 400. My code:
 

public async Task TrackEventAsync(string userId, string eventType, object eventProperties)
{
var eventData = new
{
api_key = _apiKey,
event_type = eventType,
user_id = userId,
event_properties = eventProperties
};

var json = JsonSerializer.Serialize(eventData);
var content = new StringContent(json, Encoding.UTF8, "application/json");

try
{
var response = await _httpClient.PostAsync("https://api.amplitude.com/2/httpapi", content);
response.EnsureSuccessStatusCode();
_logger.LogInformation("Event tracked successfully: {EventType}", eventType);
}
catch (HttpRequestException ex)
{
_logger.LogError(ex, "Error sending event to Amplitude: {EventType}", eventType);
}
}

Any ideas how to figure out the issue?

Hi! Getting error 400. My code:
 

public async Task TrackEventAsync(string userId, string eventType, object eventProperties)
{
var eventData = new
{
api_key = _apiKey,
event_type = eventType,
user_id = userId,
event_properties = eventProperties
};

var json = JsonSerializer.Serialize(eventData);
var content = new StringContent(json, Encoding.UTF8, "application/json");

try
{
var response = await _httpClient.PostAsync("https://api.amplitude.com/2/httpapi", content);
response.EnsureSuccessStatusCode();
_logger.LogInformation("Event tracked successfully: {EventType}", eventType);
}
catch (HttpRequestException ex)
{
_logger.LogError(ex, "Error sending event to Amplitude: {EventType}", eventType);
}
}

Any ideas how to figure out the issue?

tried to switch to https://api2.amplitude.com/2/httpapi  , but also didnt work out


Reply