C#: Get The Status Of Multiple Letters with GetLetterStatusMultiple()
Instructions
- Create a new Console Application project and add a web reference
- Copy the entire code below, delete anything written in your application and paste the code there
- Replace "MyUsername" and "MyPassword" with your PostalMethods user details
- Replace "ID1,ID2,ID3" with a comma separated list of LetterIDs for which you would like to get the status
- Start your application. If the response is -3000, you will see the status report for each letter. If the response is any other number, check the Web Service Status Codes section.
using System.IO; class Module1 { public void Main() { com.postalmethods.api.PostalWSSimple objPM = new com.postalmethods.api.PostalWSSimple(); com.postalmethods.api.GetLetterStatus_MultipleResult objResult; // // Invoke the GetLetterStatus_Multiple method // objResult = objPM.GetLetterStatus_Multiple("MyUsername", "MyPassword", "ID1,ID2,ID3"); // // Check response status // if (objResult.ResultCode == -3000) { // // -3000 means that the data was successfully retrieved. // foreach (com.postalmethods.api.LetterStatus status in objResult.LetterStatuses) { Console.WriteLine("ID: {0}", status.ID); Console.WriteLine("Last update time: {0}", status.LastUpdateTime); Console.WriteLine("Status: {0}", status.Status); Console.WriteLine(); } } else { // // A value less than -3000 means an error occured. // See the PostalMethods Status Codes: http://www.postalmethods.com/statuscodes. // Console.WriteLine("Error is:" + objResult.ResultCode); } // In debug mode, the following lines prevent your console application from closing automatically upon termination Console.WriteLine("Hit ENTER to terminate application"); Console.ReadLine(); } }
