0

I am developing a hotel booking app using expedia. I need to send the following rest data to server using the httppost

http:/api.ean.com/ean-services/rs/hotel/v3/list?minorRev=[current minorRev #]
&cid=55505
&apiKey=xxx-yourOwnKey-xxx
&customerUserAgent=xxx
&customerIpAddress=xxx
&locale=en_US
&currencyCode=USD
&city=Seattle
&stateProvinceCode=WA
&countryCode=US
&supplierCacheTolerance=MED
&arrivalDate=09/04/2012
&departureDate=09/05/2012
&room1=2
&numberOfResults=1
&supplierCacheTolerance=MED_ENHANCED
2
  • What is the format that the API is processing this call? It depends on that. Does it expect a body xml/json or it's ok if you pass all these through the url itself? Commented Mar 22, 2012 at 4:34
  • Yes , it is expecting these XML /JSON / REST formats. Please provide some codes Commented Mar 23, 2012 at 3:58

1 Answer 1

2
String urlToSendRequest = "https://example.net";
String targetDomain = "example.net";

DefaultHttpClient httpClient = new DefaultHttpClient();
HttpHost targetHost = new HttpHost(targetDomain, 80, "http");

HttpPost httpPost = new HttpPost(urlToSendRequest);

httpPost.addHeader("Content-Type", "application/xml"); 

StringEntity entity = new StringEntity("<input>test</input>", "UTF-8");
entity.setContentType("application/xml");
httpPost.setEntity(entity);

HttpResponse response = httpClient.execute(targetHost, httpPost);

Reader r = new InputStreamReader(response.getEntity().getContent());
Sign up to request clarification or add additional context in comments.

1 Comment

it is expecting these XML /JSON / REST formats. Please provide some codes

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.