CF: Get The Status Of A Letter with GetLetterStatus()

Instructions

  1. Make sure your ColdFusion environment is ready and create a new CFM page.
  2. Copy the entire code below and paste the code in the CFM page.
  3. Replace ID with the LetterID for which you would like to get the status
  4. Run your application. If the response is -3000, you will see the status report. If the response is any other number, check the Web Service Status Codes section.
<!--- /************* Settings  Begin ****************/ --->
 
<cfset webserviceUrl = 'https://api.postalmethods.com/PostalWS.asmx?WSDL'>
<cfset MyUsername = 'MyUsername'>
<cfset MyPassword = 'MyPassword'>
<!---
	check documentation for GetLetterStatus (http://www.postalmethods.com/method/getletterstatus)
--->
<cfset MyResponseID = 'MyResponseID'>
<!---
	for more details, check http://www.postalmethods.com/statuscodes#webservice
	-3000 means successfully received Web Service request
--->
<cfset ResultCodeOK = '-3000'>
 
<!--- /************* Settings  End ******************/ --->
 
 
<cfinvoke
	webservice="#webserviceUrl#"
	method="GetLetterStatus"
	returnVariable="GetLetterStatusResult" >
	    <cfinvokeargument name="Username" value="#MyUsername#">
		<cfinvokeargument name="Password" value="#MyPassword#">
		<cfinvokeargument name="Id" value="#MyResponseID#">
</cfinvoke>
 
 
<!---
	status_code is the (positive) transaction ID if successful, or a (negative) error number if unsuccessful
--->
<cfoutput>
<cfif GetLetterStatusResult.getResultCode() eq ResultCodeOK>
	Message submitted successfully for the transaction <b>#MyResponseID#</b><br>
	LetterStatus:<a href="http://www.postalmethods.com/statuscodes#webservice"><b>#GetLetterStatusResult.getStatus()#</b></a><br>
	LastUpdateTime:<b>#GetLetterStatusResult.getLastUpdateTime()#</b>
<cfelse>
	Message submission failed on error <a href="http://www.postalmethods.com/statuscodes#webservice">#GetLetterStatusResult.getResultCode()#</a>
</cfif>
 
</cfoutput>