Making Requests to XML API via Curl

I’m working on a UPS shipping class and wanted to get a feel for the UPS API before I started writing any code.  I decided to use cURL to to test.  Anyways, here’s how you format a request to an XML API via Curl / command line (Specifically, the UPS Address Validation API):

curl -v -v -d ‘<?xml version=”1.0″ ?><AccessRequest xml:lang=”en-US”> <AccessLicenseNumber>YOURLICENSENUMBER</AccessLicenseNumber><UserId>YOURUSERID</UserId><Password>YOURACCOUNTPASSWORD</Password></AccessRequest><?xml version=”1.0″?><AddressValidationRequest xml:lang=”en-US”><Request><TransactionReference><CustomerContext>General Address Validation</CustomerContext><XpciVersion>1.0001</XpciVersion></TransactionReference><RequestAction>AV</RequestAction></Request><Address><PostalCode>42167</PostalCode><StateProvinceCode>KY</StateProvinceCode></Address></AddressValidationRequest>’ -H “Content-Type:text/xml” https://wwwcie.ups.com/ups.app/xml/AV

The -v -v tells the request to be verbose, so you can see the handshake / connection happen, and get the response object. -d is for the fields of the request and -H is the content-type. The API endpoint is at the end of the code.

Figured this might save someone a few minutes = )

This entry was posted in Programming, XML, cURL. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

One Comment

  1. Posted September 7, 2011 at 10:31 pm | Permalink

    Awesome, going to work on this tonight.

One Trackback

  1. By Ups Api on May 26, 2011 at 11:50 pm

    [...] Making Requests to XML API via Curl I'm working on a UPS shipping class and wanted to get a feel for the UPS API before I started writing any code. I decided to use cURL to to test. Anyways, here's how you format a request to an XML API via Curl … Making Requests to XML API via Curl [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>