AndroidDev
AndroidDev

Reputation: 16405

Sending XML in Query String

I am integrating USPS Web API in my Java application. I have to send a request of the form

http://production.shippingapis.com/ShippingAPI.dll?API=CityStateLookup&XML=<CityStateLookupRequest%20USERID="XXXNORTH3110"> <ZipCode ID= "0"> <Zip5>22102</Zip5> </ZipCode> </CityStateLookupRequest>

Now hitting this on the browser works fine. But using this from the JAVA code breaks. How can I send XML in the Query String?

Upvotes: 2

Views: 2924

Answers (1)

Anton Krosnev
Anton Krosnev

Reputation: 4132

Why you should use POST to send this type of data: http://www.w3schools.com/tags/ref_httpmethods.asp In the POST body you don't need to encode the XML, you just need to set the correct content type "application/xml". Of course that only applies if it is valid XML and does not contain char are not allowed by XML standard.

Upvotes: 1

Related Questions