Hello, I'm trying to integrate with Mixpanel by im...
# questions
s
Hello, I'm trying to integrate with Mixpanel by importing events to https://api.mixpanel.com/import?strict=1 from my c# code but I'm getting 410 not authorized.
Copy code
var mixpanelUrlWithApiKey = $"{_config.ImportApiUrl}?strict=1";

            var request = new HttpRequestMessage
            {
                Method = <http://HttpMethod.Post|HttpMethod.Post>,
                RequestUri = new Uri(mixpanelUrlWithApiKey),
                Headers =
                {
                    {"accept", "application/json"},
                },
                Content = new StringContent(logEvent)
                {
                    Headers =
                    {
                        ContentType = new MediaTypeHeaderValue("application/json")
                    }
                }
            };
            //TODO handle errors and retries
            //var response = await httpClient.PostAsync(mixpanelUrlWithApiKey, mixpanelContent);
            using (var response = await httpClient.SendAsync(request))
            {
                response.EnsureSuccessStatusCode();
                var body = await response.Content.ReadAsStringAsync();
                Console.WriteLine(body);
                Console.WriteLine(response.IsSuccessStatusCode
                    ? $"Log event sent to Mixpanel successfully. {logEvent}"
                    : $"Failed to send log event to Mixpanel. Status code: {response.StatusCode}");

                return response;
            }
{"event":"Page View","properties":{"distinct_id":"user123","time":1700215195,"$insert_id":"d20d8ee2-d92e-404c-b16f-217e3eb8b4bd","token":"{project_token}","PageTitle":"Home","PageURL":"/home"}}
Also when trying to do requests from https://developer.mixpanel.com/reference/import-events sample api, I add my username and password and I'm getting
Copy code
{
  "error": "Not a valid service account username",
  "status": 0
}
Not sure what I'm doing wrong, and how to fix it.