CF: Get Details Of A Letter with GetLetterDetails()
Instructions
- Make sure your ColdFusion environment is ready and create a new CFM page.
- Copy the entire code below and paste the code in the CFM page.
- Replace ID with the LetterID for which you would like to get the status
- Start your application. If the response is -3000, you will see the details of your letter. If the response is any other number, check the Web Service Status Codes section.
That's it - you have successfully retrieved the details of a letter via PostalMethods. Congratulations!
<!--- /************* Settings Begin ****************/ ---> <cfset webserviceUrl = 'https://api.postalmethods.com/PostalWS.asmx?WSDL'> <cfset MyUsername = 'MyUsername'> <cfset MyPassword = 'MyPassword'> <!--- check documentation for GetLetterDetails (http://www.postalmethods.com/method/getletterdetails) ---> <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="GetLetterDetails" 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> <cfelse> Message submission failed on error <a href="http://www.postalmethods.com/statuscodes#webservice">#GetLetterDetailsResult.getResultCode()#</a> </cfif> </cfoutput>
