Due to an issue with YouTube, inserting videos in your emails is showing an error. Until they are able to resolve this issue, we recommend using a different video hosting service. We will continue to monitor this outage and update you as we have more information.
|
Hello all,
I am trying to do something simple - start a backup of contacts from the Windows command line. In this section of the API docs, Export Contacts to a File, I have tested my JSON and it is valid and starts the backup I want. However, after searching for over an hour online and trying various code excerpts, I haven't been able to get one working.
Below is what I feel was my closest attempt.
curl -v -H "Content-Type: application/json" -X POST \ -d '{"list_ids": [ "REDACTED"]}' https://api.cc.email/v3/contact_exports/?api_key=REDACTED
And this was the command line response:
Note: Unnecessary use of -X or --request, POST is already inferred. * Rebuilt URL to: \/ * Could not resolve host: \ * Closing connection 0 curl: (6) Could not resolve host: \ curl: (3) [globbing] bad range specification in column 2 curl: (3) [globbing] unmatched close brace/bracket in column 666 Note: Unnecessary use of -X or --request, POST is already inferred. * Trying 99.84.168.38... * TCP_NODELAY set * Connected to api.cc.email (99.84.168.38) port 443 (#1) * schannel: SSL/TLS connection with api.cc.email port 443 (step 1/3) * schannel: checking server certificate revocation * schannel: sending initial handshake data: sending 177 bytes... * schannel: sent initial handshake data: sent 177 bytes * schannel: SSL/TLS connection with api.cc.email port 443 (step 2/3) * schannel: failed to receive handshake, need more data * schannel: SSL/TLS connection with api.cc.email port 443 (step 2/3) * schannel: encrypted data got 4096 * schannel: encrypted data buffer: offset 4096 length 4096 * schannel: encrypted data length: 4026 * schannel: encrypted data buffer: offset 4026 length 4096 * schannel: received incomplete message, need more data * schannel: SSL/TLS connection with api.cc.email port 443 (step 2/3) * schannel: encrypted data got 1024 * schannel: encrypted data buffer: offset 5050 length 5050 * schannel: encrypted data length: 224 * schannel: encrypted data buffer: offset 224 length 5050 * schannel: received incomplete message, need more data * schannel: SSL/TLS connection with api.cc.email port 443 (step 2/3) * schannel: encrypted data got 123 * schannel: encrypted data buffer: offset 347 length 5050 * schannel: sending next handshake data: sending 126 bytes... * schannel: SSL/TLS connection with api.cc.email port 443 (step 2/3) * schannel: encrypted data got 242 * schannel: encrypted data buffer: offset 242 length 5050 * schannel: SSL/TLS handshake complete * schannel: SSL/TLS connection with api.cc.email port 443 (step 3/3) * schannel: stored credential handle in session cache > POST /v3/contact_exports/?api_key=a5d27602-fb59-452e-8ec8-6a9e4cdf8592 HTTP/1.1 > Host: api.cc.email > User-Agent: curl/7.55.1 > Accept: */* > Content-Type: application/json > Content-Length: 11 > * upload completely sent off: 11 out of 11 bytes * schannel: client wants to read 102400 bytes * schannel: encdata_buffer resized 103424 * schannel: encrypted data buffer: offset 0 length 103424 * schannel: encrypted data got 735 * schannel: encrypted data buffer: offset 735 length 103424 * schannel: decrypted data length: 706 * schannel: decrypted data added: 706 * schannel: decrypted data cached: offset 706 length 102400 * schannel: encrypted data buffer: offset 0 length 103424 * schannel: decrypted data buffer: offset 706 length 102400 * schannel: schannel_recv cleanup * schannel: decrypted data returned 706 * schannel: decrypted data buffer: offset 0 length 102400 < HTTP/1.1 404 Not Found < Content-Type: application/json < Content-Length: 102 < Connection: keep-alive < Date: Wed, 28 Aug 2019 17:02:56 GMT < x-amzn-RequestId: ae88b86d-c9b5-11e9-93de-3554c79da400 < Access-Control-Allow-Origin: * < Access-Control-Allow-Headers: Content-Type,X-Amz-Date,Authorization,X-Api-Key < x-amz-apigw-id: fJEGFEg8oAMF3bA= < Access-Control-Allow-Methods: GET,POST,PUT,DELETE,PATCH,OPTIONS < X-Cache: Error from cloudfront < Via: 1.1 9b09209d18cb42b1369b4930fcf40560.cloudfront.net (CloudFront) < X-Amz-Cf-Pop: ORD52-C2 < X-Amz-Cf-Id: 5emArlikkD1SZd562OqHIkkStFt6y-xW2f3b7OaoHKs02u0iC5eTlQ== < [ { "error_key": "not_found", "error_message": "The requested resource was not found." } ]* Connection #1 to host api.cc.email left intact
Where did it go wrong? Thanks for any help - I would love to get this working!
Hello @JWCompton,
Thank you for reaching out to Constant Contact's API Support.
The method you are using to put together your API call is including the API Key; that method is not valid for our v3 API. Here is an example of a cURL for the Bulk Activity to Export contacts.
curl -X POST \ https://api.cc.email/v3/activities/contact_exports \ -H 'Accept: text/csv' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer {access_token}' \ -H 'Cache-Control: no-cache' -d '{ "list_ids": [ "f5cb02a0-88c7-11e5-9497-d4ae5275b546" ], "fields": [ "email_address" ], "status": "active" }'
Thank you for the response but that format with the backslashes gives an error because it thinks that's the URL I want to use.
curl: (6) Could not resolve host: \ {"error_key":"unauthorized","error_message":"Unauthorized"}curl: (6) Could not resolve host: \
And here was the command I used (has to be on one line to work in Windows).
curl -X POST \ https://api.cc.email/v3/activities/contact_exports \ -H 'Accept: text/csv' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer {access_token}' \ -H 'Cache-Control: no-cache' -d '{ "list_ids": [ "f5cb02a0-88c7-11e5-9497-d4ae5275b546" ], "fields": ["email_address"], "status": "active" }'
Hello,
The back slashes are only needed when breaking up the request into multiple lines. Since you are doing this all on one line, they can be omitted. For example:
curl -X POST https://api.cc.email/v3/activities/contact_exports -H 'Accept: text/csv' -H 'Content-Type: application/json' -H 'Authorization: Bearer {access_token}' -H 'Cache-Control: no-cache' -d '{ "list_ids": [ "f5cb02a0-88c7-11e5-9497-d4ae5275b546" ], "fields": ["email_address"], "status": "active" }'
Please give this a try and let me know if that works for you.
Sincerely,
David B.
Tier II API Support Engineer