ColdFusion: Get Letter Metadata with GetLetterDetailsV2()

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 the values of the Const lines with your details:
    • Replace MyUsername and MyPassword with your PostalMethods user details.
    • Replace MyResponseID with the LetterID for which you would like to get the metadata.
  4. Start 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.
  5. <!--- /************* 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="GetLetterDetailsV2"
    	returnVariable="GetLetterDetailsResult">
    		<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 GetLetterDetailsResult.getResultCode() eq ResultCodeOK>
    	Message submitted successfully for the transaction <b>#MyResponseID#</b><br>
    	ID:<b>#GetLetterDetailsResult.getID()#</b><br>
    	Price:<b>#GetLetterDetailsResult.getPrice()#</b><br>
    	NumOfSheets:<b>#GetLetterDetailsResult.getNumOfSheets()#</b><br>
    	SubmitTime:<b>#GetLetterDetailsResult.getSubmitTime()#</b><br>
    	CompletitonTime:<b>#GetLetterDetailsResult.getCompletionTime()#</b><br>
    	Orientation:<b>#GetLetterDetailsResult.getOrientation()#</b><br>
    	Envelope:<b>#GetLetterDetailsResult.getEnvelope()#</b><br>
    	Paper:<b>#GetLetterDetailsResult.getPaper()#</b><br>
    	PrintColor:<b>#GetLetterDetailsResult.getPrintColor()#</b><br>
    	PrintSides:<b>#GetLetterDetailsResult.getPrintSides()#</b><br>
    	NationalMailing:<b>#GetLetterDetailsResult.getNationalMailing()#</b><br>
    	InternationalMailing:<b>#GetLetterDetailsResult.getInternationalMailing()#</b><br>
    	WorkMode: <b>#GetLetterDetailsResult.getWorkMode()#</b><br>
    <cfelse>
    	Message submission failed on error <a href="http://www.postalmethods.com/resources/reference/status-codes">#GetLetterDetailsResult.getResultCode()#</a>
    </cfif>
    </cfoutput>