Java post request to Overpass API


can someone help me with the source code for a java xml post request to Overpass API Interpreter?

I mean the equivalent code in java for this python sequence:

import requests
r =‘’,
data=open(‘Bethesda.xml’, ‘rb’))

Thank you!

Hi Simona,

this shouldn’t be too hard to figure out, you will find plenty of examples if you google “java post request”. Please be more specific and post some Java code if you are still having problems!


I solved the issue. Thanks!

For the benefit of everyone who arrives at this thread with the same problem in the future, it would be helpful if you posted how you solved it.

HttpClient client = new DefaultHttpClient();

	HttpPost post = new HttpPost(

	String xmlString = "....";


	try {

		HttpEntity entity = new ByteArrayEntity(xmlString


		HttpResponse response = client.execute(post);

		String resultString = EntityUtils.toString(response


	} catch (Exception ex) {


I mention that I changed the way to send the request to the interpeter. I used a xmlString instead of a xml file.