How to Fix Respondinvalid Xml in C#
I was testing the USPS Api, when I got that error. This is because of the error in my root tag, my request is as follow: API=Verify&...
https://www.czetsuyatech.com/2021/07/c-respond-invalid-xml.html
I was testing the USPS Api, when I got that error.
This is because of the error in my root tag, my request is as follow:
As written, I am calling the verify API. What I did wrong was I named the root tag, sure it works on the test server: http://testing.shippingapis.com/ShippingAPITest.dll. But it failed in the production: http://production.shippingapis.com/ShippingAPITest.dll.
Solution:
Just rename the root tag to <addressvalidaterequest>, the xml request becomes:
Note: It seems USPS is treating address1 as address2 and vice versa. Take note of this :D.
This is because of the error in my root tag, my request is as follow:
API=Verify&XML=<verifyrequest USERID='207BAZLI7194' PASSWORD='053FG85YP581'><address ID="0"> <address1></Address1><address2>Address2</Address2><city>City</City><state>State</State><zip5>Zip Code</Zip5><zip4></Zip4></Address></VerifyRequest>
As written, I am calling the verify API. What I did wrong was I named the root tag
Solution:
Just rename the root tag to <addressvalidaterequest>, the xml request becomes:
API=Verify&XML=<addressvalidaterequest USERID='207BAZLI7194' PASSWORD='053FG85YP581'><address ID="0"> <address1></Address1><address2>Address2</Address2><city>City</City><state>State</State><zip5>Zip Code</Zip5><zip4></Zip4></Address></AddressValidateRequest>
Note: It seems USPS is treating address1 as address2 and vice versa. Take note of this :D.
3 comments
Very unclear written. And you shouldn't display your user name and password!!
How did you find the correct root tag name?!
Sorry, I updated the script container long time ago and as a result broke my first set of posts just like this one. Anyway I've updated this post.
And don't worry about my username and password, it's either wrong or demo account :-)
Post a Comment