tags:

views:

31

answers:

1

I am attempting to utilize the USPS API to do some address verification/validation.

I'm sending this XML to http://testing.shippingapis.com/ShippingAPITest.dll:

<AddressValidateRequest%20USERID="xxxxx"><Address ID="0"><Address1></Address1><Address2>6406 Ivy Lane</Address2><City>Greenbelt</City><State>MD</State><Zip5></Zip5><Zip4></Zip4></Address></AddressValidateRequest>

This is the same XML that is shown in their documentation for test requests. However, I always get an HTML (instead of XML) response that is a 501 Not Implmented error. Anyone familiar with this API know what might be going on? I'm using curl (in php) to make the request

UPDATE: When I make the request by typing the url into a browser with get params, it seems to work fine, but i get the error mentioned above using php/curl or just curl from the command line.

UPDATE: If I use file_get_contents with the url, I get a 400 bad request error - but if i urlencode, it works great - solution accepted.

+1  A: 

Not familiar with the API, but:

Do you need the %20 after AddressValidateRequest? Does it work when that is replaced by a space?

Also, do you need to use CURL? Could you just use fopen() or file_get_contents() and then use the GET parameters which you mention work OK?

Lucanos
The XML shown is identical to what the USPS documentation shows with the %20 only in that one position. However, I have tried replacing it with a space AND replacing all spaces with %20. I'll give the file_get_contents method a shot first chance I get and report back. Thanks!
greggory.hz
When using file_get_contents, I get a 400 Bad Request error.
greggory.hz
Scratch that. file_get_contents works (when I urlencode >.<) This is good enough for me! Thanks!
greggory.hz