 |
|
 |
Hello, I need to create shiping labels by using the api. For that I think I need to use Shipping Labels API. I am wondering if you have any experience with it. If so can you please share some sample code? Thank you very much
|
|
|
|
 |
|
 |
i am using following code to write the image to file but it is not working.
using (MemoryStream ms = new MemoryStream(p.ShippingLabel, 0, p.ShippingLabel.Length))
{
//ms.Write(p.ShippingLabel, 0, p.ShippingLabel.Length);
ms.Seek(0,SeekOrigin.Begin);
Image returnImage;
returnImage = Image.FromStream(ms); //here is gives error, Paramter is not valid
returnImage.Save("label.tif");
}
anyone please help
|
|
|
|
 |
|
 |
I noticed the article is under the The Code Project Open License (CPOL) (able to use in commercial software, redistribute, etc.), but the code says "Copyright by Scott Smith 2006". Are we able to use this in commercial products? Thanks, and great wrapper by the way.
|
|
|
|
 |
|
 |
Just wanted to place a recent note on this one, delivery confirmation is NOT activated on the testing server, so in order to be moved to the production Server, you need to successfully call the API 2 or 3 times (I've heard both) using the other API methods such as the following, than call or email and request to be upgraded!
These were copied from test options here: http://www.usps.com/webtools/htm/Development-Guide-v3-0b.htm#_Toc205879418[^]
Good Luck!
http://www.xbox360outletstore.com
string trackingNumber = "EJ958083578US";
TrackingInfo info = new TrackingInfo();
USPSManager manager = new USPSManager("", true);
info = manager.GetTrackingInfo(trackingNumber);
Console.WriteLine(info.Summary);
Address resultAddress = new Address();
Address address = new Address();
address.Address2 = "6406 Ivy Lane";
address.City = "Greenbelt";
address.State = "MD";
address.ID = 0;
USPSManager manager = new USPSManager("", true);
resultAddress = manager.ValidateAddress(address);
|
|
|
|
 |
|
 |
Great article/library.
According to the USPS site, FirmName is limited to 38 characters. I've noticed that most of your setters do validations, but perhaps you've forgotten to include this validation for the FirmName property.
|
|
|
|
 |
|
 |
You Ever Finish The FedEx, UPS, & DHL Version Of This?
|
|
|
|
 |
|
 |
If anyone is wondering about shipping in Canada, check out purolator.com/eship for how to do it. I can give advice in more detail too.
|
|
|
|
 |
|
 |
I am completely new to XML so I'm sure I'm missing something fundamental here. I selected what looked like the simplest test - get city and state from zip - and attempted to display the results on a button click. Nuthin! Here's my code: protected void TestButton_Click(object sender, EventArgs e) { USPSManager m = new USPSManager("//my_user_id//", true); Address a = m.GetCityState("90210"); string city = a.City; string state = a.State; ResultLabel.Text = city + ", " + state; } Help plz ... thanks.
|
|
|
|
 |
|
 |
There is a bug in the library and that code won't work. Testing it myself now. Related to the earlier comment about FromXML method and the different Response types - FromXML only works with the AddressValidateRepsonse.
I'm trying with CityStateLookupResponse, and the code doesn't work.
|
|
|
|
 |
|
 |
You need to recompile this wrapper as MAX.USPS.DLL ..
USPS changed the way they return some of the XML and the programmer of this code hasn't updated to reflect that.. so that is why it doesn't work.
So before you recompile it, change the lines below..
public static Address FromXml(string xml)
{
Address a = new Address();
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.LoadXml(xml);
System.Xml.XmlNode element = doc.SelectSingleNode("/ZipCodeLookupResponse");
element = doc.SelectSingleNode("/CityStateLookupResponse/ZipCode/City");
if (element != null)
a._City = element.InnerText;
element = doc.SelectSingleNode("/CityStateLookupResponse/ZipCode/State/text()");
if (element != null)
a._State = element.InnerText;
element = doc.SelectSingleNode("/CityStateLookupResponse/ZipCode/Zip5");
if (element != null)
a._Zip = element.InnerText;
return a;
}
I am using vb.net so i add a reference to the max.usps.dll, and i just call it in a button
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Create a new instance of the USPS Manager class
'The constructor takes 2 arguments, the first is
'your USPS Web Tools User ID and the second is
'true if you want to use the USPS Test Servers.
Dim m As New MAX.USPS.USPSManager("YOUR_USER_ID", False) 'REPLACE YOUR_USER_ID with your USERID!
Dim a As MAX.USPS.Address = m.GetCityState("90210")
Dim city As String = a.City
Dim zip As String = a.Zip
Dim state As String = a.State
'Dim firmname As String = a.FirmName
MsgBox(city)
MsgBox(state)
MsgBox(zip)
End Sub
In future, if you need to understand selecting xml nodes, i recommend checking out a freeware tool like visual xpath.
Also.. you have to contact USPS a couple of times before they give you full access to production servers & all API's.
hope that helps!
modified on Friday, November 5, 2010 4:06 PM
|
|
|
|
 |
|
 |
Can some one shed some light how to process certified mail using this api?
|
|
|
|
 |
|
 |
I amd recieving 80040b1a API Authorization failure. User xxxxxxxxxxxx is not authorized to use API DeliveryConfirmationV3. UspsCom::DoAuth
|
|
|
|
 |
|
 |
Hi: I had the same problem, and fixed it by going to the production server. The test server is not set up to work with deliver confirmation. Also, you need to use the secure servers (that is in the email they send you) for the shipping label stuff. The documentation does not tell you this. You have to call them (800-344-7779) and be promoted to the production server:
'For Secure Servers (shipping labels, RMA), use these
Private Const ProductionUrl As String = "https://secure.shippingapis.com/ShippingAPI.dll"
Private Const TestingUrl As String = "https://secure.shippingapis.com/ShippingAPITest.dll"
'For Standard servers (address check, zip code check), use these
Private Const ProductionUrl As String = "http://production.shippingapis.com/ShippingAPI.dll"
Private Const TestingUrl As String = "http://testing.shippingapis.com/ShippingAPITest.dll"
Also, remember to use the: API=DelivConfirmCertifyV3 for testing label while on the production server.
Using these server settings, I'm able to retrieve the xml of the delivery confirmation number as well as the shipping label.
Good luck, tim1198
|
|
|
|
 |
|
 |
Hi,
Please get Address Vertification (Address Verify API) permissions from the USPS. I called the first time and I didn't get it. I asked for it the second time and it was activated. Here is the phone #:
Telephone: 1-800-344-7779 (7:00AM to 11:00PM ET)
Press 3
|
|
|
|
 |
|
 |
I used the above coede and getting "The remote server returned an error: (502) Bad Gateway." error
Pls help me on this
modified on Thursday, February 12, 2009 2:43 AM
|
|
|
|
 |
|
 |
I keep getting this error no matter what address zip I put in
<?xml version="1.0"?>
<Error><Number>-2147219498</Number><Source>Rate_Respond.DomesticRatesV2Test:clsRatesV2TestValidateParameters:clsRatesV2TestProcessRequest;SOLServerRatesTest.RateV2_Respond</Source><Description>Please enter a valid ZIP Code for the sender. </Description><HelpFile></HelpFile><HelpContext>1000440</HelpContext></Error>
|
|
|
|
 |
|
 |
I'm not sure which function you're validating. In general, when using the test servers to verify address or zip codes, the fields have to match exactly in order for USPS to return the xml without errors. I had to look at the documentation on webtools, and make sure that all fields match exactly like the documentation:
http://www.usps.com/webtools/htm/Address-Information.htm[^]
tim1198
|
|
|
|
 |
|
 |
How Do I Track Packages With This? i Tried The
USPSManager m = new USPSManager("YOUR_USER_ID", true);
TrackingInfo t = m.GetTrackingInfo("EJ958083578US");
But It Didn't Work What Else Do I Need To Do?
NVM! Got It Working! i had replaced the EJ958083578US with my tracking number!
modified on Wednesday, December 3, 2008 12:48 PM
|
|
|
|
 |
|
 |
HERE IS AN UPDATE
You will get this error using the V2
Call this # and have them upgrade you to the production server. You also have to ask for shipping label printing privledges too
Telephone: 1-800-344-7779 (7:00AM to 11:00PM EST)
|
|
|
|
 |
|
 |
please tell me how to show the label in pdf file or image file.
p = m.GetDeliveryConfirmationLabel(p);
regards,
|
|
|
|
 |
|
 |
public partial class LabelPrinter : Form
{
public LabelPrinter()
{
InitializeComponent();
}
public void ShowLabel(Package pack)
{
MemoryStream stream = new MemoryStream(pack.ShippingLabel);
Image tiff = Image.FromStream(stream);
this.Width = 600;
this.Height = (this.Width * tiff.Height / tiff.Width);
this.PreviewPane.Image = tiff;
}
}
Also, make sure to fix the bug in converting the returned string to a byte array.
http://www.codeproject.com/Messages/2871941/Re-HOW-TO-SHOW-PDF-FILE-FROM-UTF8-BYTE-ARRAY.aspx
|
|
|
|
 |
|
 |
Hi,
First of all many many thanks for sharing this.
I have tried your code and dll and managed to get the delivery confirmation numbers.BUT i could not able to figure out how to show the received byte array to pdf file or tif file.
please help me in this regard.
regards
sunny
|
|
|
|
 |
|
 |
The file data returned from USPS is a base64 encoded string.
Change the following in USPSManager.cs:
package.ShippingLabel = StringToUTF8ByteArray(xml.Substring(i1, i2 - i1));
To:
package.ShippingLabel = Convert.FromBase64String(xml.Substring(i1, i2 - i1));
You can then use a FileStream to output the byte array to a file.
|
|
|
|
 |
|
 |
Thanks so much for this response. Saved me hours
|
|
|
|
 |
|
 |
Yes.. saved tons of time...
thanks
--
ASif Ashraf
MCAD.Net,MCP
Asif.Log@gmail | hotmail.com
92-306-4526526
Technical Lead, Store Secured Inc.
|
|
|
|
 |