Spyros_Capetanopulos | 2018-05-18 13:24:16 UTC | #1
Hello,
I have this code in PHP to upload a CSV file to load the contact list, but at the time of loading the document, I get the error that I can not import because of problems reading the header of the document.
I have tried with JavaScript with the method that is on the following page:
https://developer.mypurecloud.com/api/tutorials/upload-contacts/#javascript
But I get the error "BAD REQUEST". and I opened a forum but nobody answered.
So, when doing it for PHP I get the error mentioned above. That he can not read the head of the document.
$filesCSV = "D:\\spyro\\Descargas\\list.csv"; $idContactList = "cd8df132-b5c2-4b6d-9a94-13354f8586b2";
$bodyCSV = "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"id\"\r\n\r\n".$idContactList."\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"file\"; filename=\"".$filesCSV."\"\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--";
$curl = curl_init();
curlsetoptarray($curl, array( CURLOPTURL => "https://apps.mypurecloud.com/uploads/v2/contactlist", CURLOPTRETURNTRANSFER => true, CURLOPTENCODING => "", CURLOPTMAXREDIRS => 10, CURLOPTTIMEOUT => 30, CURLOPTHTTPVERSION => CURLHTTPVERSION11, CURLOPTCUSTOMREQUEST => "POST", CURLOPTPOSTFIELDS => $bodyCSV, CURLOPTHTTPHEADER => array( "Authorization: Bearer w4znhPMiWKShadOYCbIHmVvHso9MUvxO0nSZXF3ZtIYGFTew0ISm-WoAqpSin3KuJMSdXIFh57Eqt5KOgJi9Eg", "Cache-Control: no-cache", "Postman-Token: 243828a3-6542-4a15-8904-857597708f52", "content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW" ), ));
$response = curlexec($curl); $err = curlerror($curl);
curl_close($curl);
if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }
This is what the CSV file contains:
And this is what answers
{"correlationId":"93e39638-90e5-43dd-a068-68148449e07a"}
But this error occurs in the Purecloud administrator.
I hope you can help me.
Thank you
tim.smith | 2018-05-18 14:16:03 UTC | #2
So the upload is successful but the import ultimately fails? Is that correct? If so, please open a ticket with PureCloud Support as the API is working correctly and some internal process in PureCloud is having an error.
system | 2018-06-18 14:16:04 UTC | #3
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: 2884