Enter the Share Your Success Sweepstakes 2024 For the Chance to Win Great Prizes!

Bulk Import from CSV

AmandaA4528
Rookie
0 Votes
I've used postman to create all the calls for an application we're building... I'm converting those calls to C#, so far everything has been working great, Auth, Token Refresh, getting campaign info, getting contact Lists. What i can't get working is the bulk import from CSV. static async Task ImportContactsFromCsvAsync() { try { //var client = new HttpClient(); //there is one global one for the whole program var request = new HttpRequestMessage(HttpMethod.Post, https://api.cc.email/v3/activities/contacts_file_import); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "+accessToken); var content = new MultipartFormDataContent(); content.Add(new StreamContent(File.OpenRead("CCTEST2.csv")), "file", "CCTEST2.csv"); content.Add(new StringContent("afefdcac-7fe9-11ee-8918-fa163e504c74"), "list_ids"); request.Content = content; var response = await client.SendAsync(request); //response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); } catch (Exception ex) { Console.WriteLine($"An error occurred: {ex.Message}"); } return; } [{"error_key":"http.status.bad_request","error_message":"Unable to parse the request body as multipart form-data."}] I keep getting bad request, i've started going down the route of manually building the request with lower level functions, but so far have not had any luck.
1 REPLY 1
Courtney_E
Moderator
0 Votes

Hello AmandaA4528,

 

Thank you for reaching out to Constant Contact API Developer Support. My team is here to assist outside software developers with questions about building into Constant Contact's API.

 

It looks like we've already followed up with you directly via email, but I wanted to close the loop here as well. If you haven't received our reply, please let us know via email at webservices@constantcontact.com, and reference case number 31783532.

 

While our expertise is with our API itself as opposed to its implementation within any particular programming language, we are happy to answer any questions pertaining to Constant Contact’s API endpoints, functionality, and documentation.

 

Please have a look and let us know if you have any other questions!


Regards,

Courtney E.
Tier II API Support Engineer

Did I answer your question?
If so, please mark my post as an "Accepted Solution" by clicking the Accept as Solution button in the bottom right hand corner of this post.
Resources
Developer Portal

View API documentation, code samples, get your API key.

Visit Page

Announcements

API Updates

Join our list to be notified of new features and updates to our V3 API.

Sign Up