Legacy Dev Forum Posts

 View Only

Sign Up

Is there a C#.NET sample to upload CSV file to contact lists?

  • 1.  Is there a C#.NET sample to upload CSV file to contact lists?

    Posted 06-05-2025 18:05

    rboddu | 2018-01-19 19:24:22 UTC | #1

    Is there a C#.NET sample to upload CSV file to contact lists?

    https://developer.mypurecloud.com/api/tutorials/upload-contacts/#javascript


    tim.smith | 2018-01-22 20:10:48 UTC | #2

    There isn't. You can follow those tutorials in other languages or review the page Upload Contact Lists. Are you having an issue or just asking?


    rboddu | 2018-01-27 16:51:54 UTC | #3

    I am having an issue uploading CSV file as in the Javascript example from a .NET core console app using C# or RestSharp. There is no exception on ExecuteAsync.

    var client = new RestClient("https://apps.mypurecloud.com/uploads/v2/contactlist"); var request = new RestRequest(Method.POST); request.AddHeader("authorization", string.Format("Bearer " + accessToken)); request.AddHeader("content-type", "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW");

    request.AddParameter("multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW", "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"id\"\r\n\r\nc7212b07-2544-4e16-8939-ed2081fb563f\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"file\"; filename=\"RECOBM_090.csv\"\r\nContent-Type: text/csv\r\n\r\n\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"fileType\"\r\n\r\ncontactlist\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"contact-id-name\"\r\n\r\nContact ID\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--", ParameterType.RequestBody);

    string result = string.Empty; client.ExecuteAsync(request, (response) => { if (response.StatusCode == HttpStatusCode.OK) result = "Upload completed succesfully...\n" + response.Content; else result = response.StatusCode + "\n" + response.StatusDescription; });


    tim.smith | 2018-01-29 18:20:02 UTC | #4

    So what's happening when you run the code? Are you getting a successful response? Are the contacts being imported? Can you grab the correlation ID from the response header?


    system | 2018-03-01 18:25:11 UTC | #5

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 2380