I'm trying to write a Mule flow to poll a CRUD-web service. I've managed to do kind of what I'd like to do with a small JAVA-application but I'd like to use a HTTP-endpoint in a mule flow instead if its possible.
I'd like to do a HTTP-GET-request with Database ID in the HTTP-HEADER. Is this possible with a MULE-inbound-endpoint?
// HTTP GET request
private void sendGet() throws Exception {
String url = "https://XXXXXXXXXXXXXXXXXXXXXXXXXX";
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
// optional default is GET
con.setRequestMethod("GET");
con.setRequestProperty("X-Appery-Database-Id", "XXXXXXXXXXXXXXXXXX");
//add request header
con.setRequestProperty("User-Agent", USER_AGENT);
int responseCode = con.getResponseCode();
System.out.println("\nSending 'GET' request to URL : " + url);
System.out.println("Response Code : " + responseCode);
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
//print result
System.out.println(response.toString());