Reply
Participant
pgplanning
Posts: 10
Registered: ‎06-14-2010

The web site you are accessing has experienced an unexpected error.

I use the coldfusion API, and got this error: The web site you are accessing has experienced an unexpected error.




 

CTCT Employee
David_J
Posts: 510
Registered: ‎06-04-2009

ColdFusion API

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.

David J

Participant
pgplanning
Posts: 10
Registered: ‎06-14-2010

Coldfusion API

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,


You can do the following operations Add a new Contact | Add a new Contact | Add or Edit Contact | List all contacts


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.

CTCT Employee
David_J
Posts: 510
Registered: ‎06-04-2009

RE: ColdFusion API

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.

David J

Participant
pgplanning
Posts: 10
Registered: ‎06-14-2010

CFMX 7 and 8

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?

CTCT Employee
David_J
Posts: 510
Registered: ‎06-04-2009

LOCAL scope

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"))>

<cfdump var="#contactDetails#">

 

David J

Participant
pgplanning
Posts: 10
Registered: ‎06-14-2010

I try your testing code

I try the testing code you gave, and it works, I can retrieves contact XML. so, what is next, do I need to use this code in the API? thanks

Participant
pgplanning
Posts: 10
Registered: ‎06-14-2010

still getting error

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.
CTCT Employee
David_J
Posts: 510
Registered: ‎06-04-2009

RE: LOCAL scope

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.

David J

Participant
pgplanning
Posts: 10
Registered: ‎06-14-2010

Fix code

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.