LucasRocha | 2017-04-26 18:03:21 UTC | #1
Hello!
I'm currently working in a upload integration in salesforce for the purecloud api. I couldn't find much info about using upload contact lists beside whats listed in https://developer.mypurecloud.com/api/rest/v2/outbound/uploadcontactlists.html .
Anyway, so far I got to this code to format the request body:
body = body + boundary + '\n'; body = body + 'Content-Disposition: form-data; name="file"; filename="ContactUpload.csv"\nContent-Type: application/vnd.ms-excel\n\n'; body = body + EncodingUtil.base64Encode(file) + '\n'; body = body + '\n' + boundary + '\n'; body = body + 'Content-Disposition: form-data; name="fileType"\n\n'; body = body + 'contactlist'; body = body + '\n' + boundary + '\n'; body = body + 'Content-Disposition: form-data; name="id"\n\n'; body = body + idListContatoPurecloud; body = body + '\n' + boundary + '\n'; body = body + 'Content-Disposition: form-data; name="contact-id-name"\n\n'; body = body + 'inin-outbound-id'; body = body + '\n' + boundaryF;
Edit: file is defined as Blob file = Blob.valueof(csv) and csv is a string type var.
The server responds with a status code 400 with no further details. Ideas anyone? Thanks in advance!
tim.smith | 2017-04-26 18:14:36 UTC | #2
Can you provide the correlation ID from the response header?
LucasRocha | 2017-04-26 19:13:39 UTC | #3
Cant find it anywhere in the response header. The info presented in the header are: Server: nginx/1.10.1 Access-Control-Allow-Origin: * Access-Control-Allow-Methods: POST Connection: keep-alive Content-Length: 0 Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization Date: Wed, 26 Apr 2017 19:10:25 GMT
tim.smith | 2017-04-26 19:59:43 UTC | #4
I'm not sure exactly what's wrong with your request, but it's malformed in some way. I tested the javascript contact upload tutorial and it's working correctly. I would recommend giving that a try and comparing the request it sends with the request your code is sending.
I've opened UP-15 to have the correlation ID added to the response headers. Unfortunately, it's not currently being set.
LucasRocha | 2017-04-27 14:13:14 UTC | #5
Finally found the error origin, instead of sending '\n' I'm now using '\r\n' and now I'm receiving response 200. But the contact list does not change! The correlation Id: ebce61b1-cf9b-4ac4-ab40-d084f348d76d. Any sugestion on this?
tim.smith | 2017-04-27 16:27:54 UTC | #6
The error is "Missing ImportListType property during file upload"
tim.smith | 2017-04-27 16:42:41 UTC | #7
Here's a few resources to help:
LucasRocha | 2017-04-27 21:00:30 UTC | #8
Thanks, Tim! I had some succesfull requisitions and now it stopped again. Using the tools you suggested it returns an import status that seems to be old.
The correlation id for the call is 1aaeb389-6e97-4b15-9f01-553e445d6bb4. Can you help me with this one?
tim.smith | 2017-04-27 21:07:39 UTC | #9
The error for that correlation ID is "Missing ImportListType property during file upload"
LucasRocha | 2017-04-27 22:06:29 UTC | #10
Tim, where can I set this option? I'm sending in the body, but I'm not sure if its the field you are refering to.
Content-Disposition: form-data; name="fileType"
contactlist
LucasRocha | 2017-04-28 12:40:09 UTC | #11
Seems that I was missing a ' character somewhere in the CSV string var. Its working now, thank you very much, Tim!
system | 2017-08-28 19:34:12 UTC | #12
This post was migrated from the old Developer Forum.
ref: 1231