cancel
Showing results for 
Search instead for 
Did you mean: 

Incomplete XML

Highlighted
Occasional Participant

Incomplete XML

Hi,


I seem to be getting incomlete XML back from the API. I'm making a request to a URL in this format:



https://<api_key>%<username>:<password>@api.constantcontact.com/ws/customers/<username>/campaigns/<campaign_id>

The XML cuts off somewhere in the `<EmailContent>` node. Since the XML is incomplete, it's not well-formed; when I try to load the XML as a SimpleXML object in PHP, my script chokes (as you would expect).


 


Anybody know why the data I'm getting back from the API is incomplete?


Thanks,

Paul

4 REPLIES 4
Highlighted
CTCT Employee

Firstly, I noticed that you

Firstly, I noticed that you are including your username and password in the request URI which is not recommended. If you are using cURL to perform a request you should be setting your authentication type and sending your credentials like so:


 


$userNamePassword = $Key . '%' . $UN . ':' . $PW ;

curl_setopt($session, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);

curl_setopt($session, CURLOPT_USERPWD, $userNamePassword);


 


I was not able to replicate receiving incomplete data with my request. One thing that I can suggest is that the problem may lie with the SimpleXML process rather than the data being returned.


 


Can you attempt to display the body that is being returned rather than what the SimpleXML function is parsing. This wil help to identify where the source of the issue is.

Dan H

Support Engineer, Constant Contact

Highlighted
Occasional Participant

Hi Dan,   Thanks for the

Hi Dan,


 


Thanks for the security tip. I'll consider switching over to cURL.


 


As for SimpleXML, that's not where the problem lies. When I realized that SimpleXML couldn't load the data, I printed the response from the API directly, before running any functions on the data. That is how I determined that the XML is cut off in the middle of `<EmailContent>`. 


 


Paul

Highlighted
CTCT Employee

Considering that you get the

Considering that you get the incomplete XML as a direct response from the API and considering that it is in the EmailContent node suggests that there is some sort of un-encoded character causing the API to think it has reached the end of the data. The API should only accept encoded angle brackets so it may not be those but it could be another character.


 


Can you provide me with the last few characters that are being returned?

Dan H

Support Engineer, Constant Contact

Moderator

We have done some additional

We have done some additional work regarding this issue and have replicated the problem you're seeing.  In our example, which our developers are looking into now, there are symbols included in the HTML which were not inserted as HTML entities by copy/pasted in instead.  Our example was Word left and right double quotes, however there are many symbols that can cause this.  This would be the first thing I would recommend looking into, you'd be able to see this by editing the email in your account and looking for non-displayable character symbols in yoour HTML code (squares in IE or diamonds in FF).

Dave Berard
Senior Product Manager, Constant Contact