I use the coldfusion API, and got this error: The web site you are accessing has experienced an unexpected error.
I'd be happy to help you with this. If you could please let me know what you were doing and what page you were on when you received this error and I can certainly look into it for you and do some testing on my end.
Basically, I just download the sample code of Coldfusion from your website and install in on my local coldfusion server to test it. I follow the documentation, the only thing I change is the loging part:
<cfset APPLICATION.ccUsername = "PGPlanning"> <!--- Username for your account --->
<cfset APPLICATION.ccPassword = "my password here"> <!--- Password for your account --->
<cfset APPLICATION.apiKey = "bc09e9f6-4d2c-4e52-a65d-00c0032d72e8"> <!--- Api Key for your account --->
Then I run it,
All the links give me error, for example, when I click on List all contacts, I got this error message: Variable NEXTEXIST is undefined.
The error occurred in <b><generated>: line 1
Called from C:\mncppcapps.org\apps\planning\constantcontact\Contacts.cfc: line 57
Called from</b> C:\mncppcapps.org\apps\planning\constantcontact\list.cfm: line 19
I am using CFMX 7. Hope you can help.
I have tested this with ColdFusion 9 and not received any errors like this. I will do some testing with different versions of ColdFusion (including MX7) and let you know if I am able to replicate this issue.
Thank you for following up. I have tested it on CFMX 7 and 8, both are not working, got the same error message. When I try to do some debug, I notice the doServerCall function is not returning anything. If I put the <cfhttp> call inside the individual files instead of application.cfc, it will get the XML back. any idea?
The doServerCall function just performs cfhttp requests (get, put, post, delete) and returns whatever is retrieved from that as cfhttp.filecontent. It is only used by other functions like getContactDetails, editContact, removeContact etc. I am wondering if using the new LOCAL scope in those functions could be causing an issue with a version of ColdFusion prior to 9. I am going to continue to attempt to replicate this issue on my end.
If you were to place the following code inside a new page (in the same folder as the other files) this would use only the doServerCall function and not any of the other functions utilizing the local scope. I am curious if this also throws you any errors or if it successfully retrieves contact XML.
<cfset utility = createObject("component", "Application")>
<cfset contactDetails = XmlParse(utility.doServerCall("get", "#application.apipath#/contacts/1"))>
I put you test code inside the API, and now it's getting this error:
An error occured while Parsing an XML document.
Content is not allowed in prolog.
Also, it says variable is not defined, if I get rid of Local., the not defined error is gone.
I did some testing on a virtual machine running ColdFusion8 and was able to replicate the error message that you were having. It does appear that the LOCAL scope that was introduced in ColdFusion9 does not function in any prior versions of CF. This issue can be resolved by either removing any instance of "LOCAL." from the entire document (find "LOCAL." and replace with ""), or by manually rescoping these variables using the 'var' scope.
I will be either adjusting the scoping in the ColdFusion sample to order to maintain backwards compatibility, or publishing an FAQ on how to manually adjust the scopes of these variables in the near future, and will update this thread when that is complete.
Regarding the error messaging you are receiving:
An error occurred while Parsing an XML document.
Content is not allowed in prolog.
This is due to the XmlParse function not being able to read the content of whatever variable you are attempting to parse as XML. This is often caused by the server returning an error message rather than actual XML, likely due to an invalid request. If you'd like the send the code you are using to produce this I would be happy to take a look at it. Alternatively, you could wait until I have published the new ColdFusion sample or created an FAQ on updating the sample for earlier versions of ColdFusion - as this would likely resolve the issue that forced you to modify the code in the first place.
I apologize for any inconvenience that this issue has caused, but thank you for bringing this to our attention so that it can be resolved. Please feel free to post any other questions. Thank You.
So basically what I can do is to get rid of all the local.? I will see if it works for me. Otherwise I will wait for you to post the new sample code. For An error occurred while Parsing an XML document.
Content is not allowed in prolog. some people say this is usually due to the calling of web service?
Thank you for all your help. Looking forward to your revised sample code.
When I click on list all contacts, I am getting this error message:
coldfusion.runtime.RequestTimedOutException: The request has exceeded the allowable time limit Tag: cfhttp
and I increase the timeout in cfhttp, still get the same error.
The current getContacts() function is meant to aggregate all contacts in the account. This has proven to be a bit too heavy of a server call for accounts with a high number of contacts. This is something I have already changed for the next sample pack update which will have the revised getContacts() function that retrieves 50 contacts at a time, as well as removing the LOCAL. scope. Again, this update is nearly finished and I will be posting that in the very near future. I will update this thread when it is complete.
I have updated the ColdFusion Sample Contact Upload Form, which you can now download on our Sample Codes page. This update has a modified getContacts function which will now return a paginated response of 50 contacts at a time, as well as a link to the next page of contacts returned from our API. This should resolve the issue you were experiencing with list.cfm.
I have also modified the scope of the variables used in List.cfc and Contacts.cfc. I have tested this in both ColdFusion8 and 9 environments, and have not run into any errors that were encountered by running the previous sample pack with versions of ColdFusion prior to 9.
Please let me know if you run into any further difficulties with the updated sample. Thank you for your patience while we resolved this.
Thank you for your support, the all works prefectly, the only issue I have is the add or edit contact is not openning in IE, but works fine in Firefax. Maybe you can look into it later.
I have made a slight modification which resolved this issue. If you use the code below as your "edit.cfm" this will allow the form to display in both IE and FF. I have also updated the ColdFusion sample pack with this change. Thank you for pointing this out.
<!--- If form is submitted --->
<cfset contactExists = createObject("component", "Contacts").searchContact(FORM.email)>
<!--- If the contact exists, the id is passed to edit_full.cfm to edit the contact --->
<cfif contactExists NEQ false>
<cflocation url="edit_full.cfm?id=#contactExists#" />
<cfoutput><div align="left" class="mainText">Contact #FORM.email# does not exist. <a href="add.cfm?email=#FORM.email#">Click here to add them</a></div></cfoutput>
<!--- Search form --->
<cfform format="flash" name="search" action="edit.cfm" method="post" skin="haloBlue">
<cfformgroup type="panel" label="Enter Contact Email Address" width="350">
<cfinput type="text" name="email" label="Email Address" required="yes" validate="email" width="200" >
<cfinput type="submit" value="submit" name="submit">