The Community is hosting an End of Summer sweepstakes! Participants must complete tasks to earn tickets that will enter them with a chance to win a free year of Constant Contact and other great prizes!*
*No Purchase Necessary. For Official Rules, visit here. Constant Contact’s End of Summer 2020 Sweepstakes ends on October, 20, 2020 at 11:50 PM EST.

Sends count not the same in account report and API

Highlighted
Occasional Advisor

Sends count not the same in account report and API

Can you tell me why our sends show through the API as 50 and our report in our account shows 104. We have checked the content of he response and there are only 50 email addresses in it.


Thank you,


Charles

Thank you,


Charles

15 REPLIES 15
Highlighted
Employee

50 items at a time

Hello,



All of our URI's only return 50 items at a time. If there are more than 50 items that need to be returned, there will be a next link node near the top of the XML. An example of this node is this:



<link href="/ws/customers/ACCOUNT/contacts?next=ggvhf5p7-13y1ag" rel="next"></link>



If you have any questions please let me know.



Regards,

Benjamin Soder
NOC Analyst
Constant Contact
Highlighted
Occasional Advisor

How can we get the next,next,next etc...

Ben,


We use asp.net and vb.net, so we typically use a dataset to read the xml responses from an api. This has served us well until we had to read your event xml response with nested links. So we found a way around it by parsing out the email addresses from the response returned by bounces, opens, sends, etc.. and doing a count in code. But now that we know that a response will only return 50 eamils at time. I'm not sure how we will get the next group of emails and add them to the previous or previous groups.


We are simply trying to dispaly the results of a selected email on our asp.net web page.


Anything you can sare would be very appreciated.


 


Dim sUri As String = "https://api.constantcontact.com" & strURI


Dim sAPIKey As String = "?????"


'setup httpWebReqeust to send the request


Dim address As New Uri(sUri)


Dim theRequest As HttpWebRequest = TryCast(WebRequest.Create(address), HttpWebRequest)


theRequest.Credentials = New NetworkCredential((sAPIKey & "%" & ctu), ctp)


theRequest.Method = "GET"


theRequest.ContentType = "application/vnd.ctct+xml"


Using theResponse As HttpWebResponse = TryCast(theRequest.GetResponse(), HttpWebResponse)


Dim responseStream As Stream = theResponse.GetResponseStream()


Dim streamReader As StreamReader = New StreamReader(responseStream)


Dim responseText As String = streamReader.ReadToEnd


Dim contents As String = responseText.ToString


If contents.Length = 0 Then Exit Sub


' search for email addresses


Dim i As Integer = 0


Dim intCount As Integer = 0


Dim emails As String()


Dim email As String


Dim results As New StringBuilder


emails = ExtractEmailAddressesFromString(contents)


For Each email In emails


intCount += 1


results.Append(email & vbNewLine)


Next

 

Thank you,


Charles

Highlighted
Occasional Advisor

Getting total of sent emails

Hello,


In order to retrieve the total number of opens, sends, bounces, etc, I would recommend performing an HTTP GET on the following URI:


 


https://api.constantcontact.com/ws/customers/{username}/campaigns/{campaignID}


 


In the XML returned, there are nodes for sends, opens, clicks, bounces, forwards, optouts, and spam reports containing the total number, eliminating the need for you to count each individual email entry.


 


If you are looking to retrieve not only a count but also require the individual email addresses, you will need to perform an HTTP GET on the following URI:


 


https://api.constantcontact.com/ws/customers/{username}/campaigns/{campaignID}/events/{eventType}


 


Where eventType is the type of event you wish to retrieve such as opens, bounces, etc. Please note that with this particular request, you can change the default number of addresses returned from 50 to any number from 1 to 200 by appending '?pageSize={1-200}' to the request URI.


 


example:


https://api.constantcontact.com/ws/customers/{username}/campaigns/{campaignID}/events/{eventType}?pageSize=200


 


In order to retrieve the next chunk of email addresses, you will need to perform an additional HTTP GET to URI of the next set of data. This URI can be found in the link attribute of the initially returned XML with the rel attribute of 'next'.

Andrew T

Support Engineer, Constant Contact

Highlighted
Occasional Advisor

Too many nested links in your xml

Andrew,


We were excited for a moment, but we get the same error as we had previously;


Can you take a look and make a suggestion?


Thank you,


We also tried viewing the responseText and did not see any counts in the string returned:


Dim responseStream As Stream = theResponse.GetResponseStream()

Dim streamReader As StreamReader = New StreamReader(responseStream)

Dim responseText As String = streamReader.ReadToEnd


Dim contents As String = responseText.ToString

If contents.Length = 0 Then Exit Sub


lblContents.Text = contents.ToString()


Nested table 'link' which inherits its namespace cannot have multiple parent tables in different namespaces.


We tried your suggested uri below, using our code also listed below. This is where we get the error.


https://api.constantcontact.com/ws/customers/{username}/campaigns/{campaignID}

Dim sUri As String = "https://api.constantcontact.com/ws/customers/" & ctu & "/campaigns/" & strCampaignID

Dim sAPIKey As String = "???????"


'setup httpWebReqeust to send the request

Dim address As New Uri(sUri)

Dim theRequest As HttpWebRequest = TryCast(WebRequest.Create(address), HttpWebRequest)

theRequest.Credentials = New NetworkCredential((sAPIKey & "%" & ctu), ctp)


theRequest.Method = "GET"

theRequest.ContentType = "application/vnd.ctct+xml"


Using theResponse As HttpWebResponse = TryCast(theRequest.GetResponse(), HttpWebResponse)

'load dataset with xml response

Dim xtr As New XmlTextReader(theResponse.GetResponseStream())

xtr.ReadString()

Dim dscte As New DataSet()

dscte.ReadXml(xtr)



'Create the xml file to check what we are receiving.

dscte.WriteXml("C:\Documents\Data.xml")

End Using

Thank you,


Charles

Highlighted
Occasional Advisor

Thought I would add

Andrew,


When we view the responseText returned, it appears as if we are not getting all the text. But even more interesting is that it appears to be text from the email that was sent. There are no Bounce, Optout, Send, or Open counts in the responseText.


Could you please verify the uri format you gave use should be returning counts? If not please provide the correct format.


Thank you very much,


Charles


Dim responseStream As Stream = theResponse.GetResponseStream()

Dim streamReader As StreamReader = New StreamReader(responseStream)

Dim responseText As String = streamReader.ReadToEnd


Dim contents As String = responseText.ToString()

If contents.Length = 0 Then Exit Sub


lblContent.Text = contents.ToString()

Thank you,


Charles

Highlighted
Occasional Advisor

URI Format

Hello,


Yes, performing an HTTP GET on https://api.constantcontact.com/ws/customers/{username}/campaigns/{campaignID} returns the following XML:


(Note lines 17-23)


 


<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns="http://www.w3.org/2005/Atom">
<link href="/ws/customers/joesflowers/campaigns/1100545398420" rel="edit" />
<id>http://api.constantcontact.com/ws/customers/joesflowers/campaigns/1100545398420</id>
<title type="text">joesflowers custom campaign HTML</title>
<updated>2009-10-01T18:42:56.939Z</updated>
<author>
<name>Constant Contact</name>
</author>
<content type="application/vnd.ctct+xml">
<Campaign xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.
com/ws/customers/joesflowers/campaigns/1100545398420">
<Name>joesflowers custom campaign HTML</Name>
<Status>Draft</Status>
<Date>2009-10-01T18:42:56.939Z</Date>
<LastEditDate>2009-10-01T18:43:40.656Z</LastEditDate>
<Sent>0</Sent>
<Opens>0</Opens>
<Clicks>0</Clicks>
<Bounces>0</Bounces>
<Forwards>0</Forwards>
<OptOuts>0</OptOuts>
<SpamReports>0</SpamReports>
<SharePageURL>http://myemail.constantcontact.com/Learn-more-about-me.html?soid=xxxxxx&amp;aid=aknBCDE</SharePageURL>
<Subject>Enter email subject here</Subject>
<FromName>joesflowers</FromName>
<CampaignType>CUSTOM</CampaignType>
<ViewAsWebpage>YES</ViewAsWebpage>
<ViewAsWebpageLinkText>Click here</ViewAsWebpageLinkText>
<ViewAsWebpageText>Having trouble viewing this email?</ViewAsWebpageText>
<PermissionReminder>YES</PermissionReminder>
<PermissionReminderText>You're receiving this email because of your relationship with Constant Contact. Please &lt;
ConfirmOptin>&lt;a style="color:#0000ff;">confirm&lt;/a>&lt;/ConfirmOptin> your continued interest in receiving
email from us.</PermissionReminderText>
<GreetingSalutation>Dear</GreetingSalutation>
<GreetingName>First_Name</GreetingName>
<GreetingString>Greetings!</GreetingString>
<OrganizationName>Constant Contact</OrganizationName>
<OrganizationAddress1>1601 Trapelo Rd.</OrganizationAddress1>
<OrganizationAddress2></OrganizationAddress2>
<OrganizationAddress3></OrganizationAddress3>
<OrganizationCity>Waltham</OrganizationCity>
<OrganizationState>MA</OrganizationState>
<OrganizationInternationalState></OrganizationInternationalState>
<OrganizationCountry>us</OrganizationCountry>
<IncludeForwardEmail>YES</IncludeForwardEmail>
<ForwardEmailLinkText>Forward email</ForwardEmailLinkText>
<IncludeSubscribeLink>YES</IncludeSubscribeLink>
<ArchiveStatus>Published</ArchiveStatus>
<ArchiveURL>http://archive.constantcontact.com/fs048/1100545398420/archive/1100552358978.html</ArchiveURL>
<EmailContentFormat>HTML</EmailContentFormat>
<EmailContent>&lt;!-- If your HTML code DOES include the html, head, and body tags,
replace the entire code below with your custom HTML code.

Please note, if you want to use the Constant Contact personalized greeting,
make sure to add the &lt;Greeting/> tag to your code. -->

&lt;html>
&lt;body>
&lt;Greeting />
&lt;!-- If your HTML code DOES NOT include the html, head, and body tags,
paste your custom HTML code between the START and END comments -->
&lt;!-- START -->


&lt;!-- END -->
&lt;/body>
&lt;/html></EmailContent>
<EmailTextContent>&lt;Text>
&lt;Greeting />
&lt;/Text></EmailTextContent>
<StyleSheet></StyleSheet>
<ContactLists>
<ContactList id="http://api.constantcontact.com/ws/customers/joesflowers/lists/2">
<link xmlns="http://www.w3.org/2005/Atom" href="http://api.constantcontact.
com/ws/customers/joesflowers/lists/2" rel="self" />
</ContactList>
</ContactLists>
<FromEmail>
<Email id="http://api.constantcontact.com/ws/customers/joesflowers/settings/emailaddresses/1">
<link xmlns="http://www.w3.org/2005/Atom" href="http://api.constantcontact.
com/ws/customers/joesflowers/settings/emailaddresses/1" rel="self" />
</Email>
<EmailAddress>joesflowers@constantcontact.com</EmailAddress>
</FromEmail>
<ReplyToEmail>
<Email id="http://api.constantcontact.com/ws/customers/joesflowers/settings/emailaddresses/1">
<link xmlns="http://www.w3.org/2005/Atom" href="http://api.constantcontact.
com/ws/customers/joesflowers/settings/emailaddresses/1" rel="self" />
</Email>
<EmailAddress>joesflowers@constantcontact.com</EmailAddress>
</ReplyToEmail>
</Campaign>
</content>
<source>
<id>http://api.constantcontact.com/ws/customers/joesflowers/campaigns</id>
<title type="text">Campaigns for customer: joesflowers</title>
<link href="http://api.constantcontact.com/ws/customers/joesflowers/campaigns" />
<link href="http://api.constantcontact.com/ws/customers/joesflowers/campaigns" rel="self" />
<author>
<name>joesflowers</name>
</author>
<updated>2009-10-01T18:43:40.731Z</updated>
</source>
</entry>

Andrew T

Support Engineer, Constant Contact

Highlighted
Occasional Advisor

We are not getting the same xml returned when we do a GET

Andrew,


We re not getting the same xml as your example when we do an HTTP GET to your suggested uri. Here is a sample of the uri we used and below it is a sample of the string returned:


No where in the returned string is there any counts or count tags.


https://api.constantcontact.com/ws/customers/our use name/campaigns/1103693687862


http://api.constantcontact.com/ws/customers/our user name/campaigns/1103693687862 2010-10-04T23:10:15.530Z Constant Contact 2010 Q3 New Template Sent 2010-10-04T23:10:15.530Z 2010-09-17T01:14:24.247Z 2010-10-04T23:10:15.493Z 104 23 6 18 0 1 0 http://myemail.constantcontact.com/Latest-Edition-of-efsNews--With-New-Easy-to-Read-Look-.html?soid=1101594189982&aid=OpunUx1WtAk Latest Edition of efsNews (With New Easy-to-Read Look)


 

Thank you,


Charles

Highlighted
Occasional Advisor

Hello Charles, The XML

Hello Charles,


The XML response you have provided does in fact contain your total numbers. Please note the string of numbers you have, 104,23,6,18,0,1,0.


 


The XML response returned by the server is as follows:



<Campaign xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.com/ws/customers/joesflowers/campaigns/1102414826616">
<Name>Copy of Jen R5 Deployment</Name>
<Status>Sent</Status>
<Date>2009-01-18T14:00:04.681Z</Date>
<LastEditDate>2009-01-17T13:53:12.932Z</LastEditDate>
<LastRunDate>2009-01-18T14:00:04.676Z</LastRunDate>
<Sent>1</Sent>
<Opens>1</Opens>
<Clicks>1</Clicks>
<Bounces>0</Bounces>
<Forwards>0</Forwards>
<OptOuts>0</OptOuts>
<SpamReports>0</SpamReports>




Looking at your posted XML response, the last timedate stamp is the LastRunDate. The numbers after that correspond to sent, opens, clicks, bounces, forwards, optouts, and spamreport totals.

Based off of your data, that means you have 104 Sent,23 Opens,6 Clicks,18 Bounces,0 Forwards,1 optout,0 spamreports.

 

Andrew T

Support Engineer, Constant Contact

Highlighted
Occasional Advisor

No way to parse out the counts

Andrew,


The vb.net (3.5) dataset xml reader will not read the response returned by the uri. That's what lead me to try and parse out the counts, but that would be a thing that nightmares are made of. When we try and read the response into our dataset xml reader we get an illegal character in path error. Do you have any suggestions on this or do you know of another way we can get the counts we need?


I very much appreiate your help with this!

Thank you,


Charles

Developer Portal

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

Visit Page

Constant Contact 2020 End of Summer Community Sweepstakes!

The Constant Contact User Community is hosting a sweepstakes. The more you participate, the more chances you have to win! Read on to learn more...

Read More
Featured