import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.async.Callback;
import com.mashape.unirest.http.exceptions.UnirestException;
import java.util.concurrent.Future;
public class WebHookAdapter {
private static Unirest unirest = new Unirest();
static String webhookEndpoint;
public static void main(String[] args) {
Future<HttpResponse<JsonNode>> future = send("ldjflksdfj");
}
public static Future send(String text) {
String json = "{\"text\" : \"" + text + "\"}";
Future<HttpResponse<JsonNode>> future;
future = unirest.post(webhookEndpoint).header("Content-Type", "application/json").body(json).asJsonAsync(new Callback<JsonNode>() {
@Override
public void completed(HttpResponse<JsonNode> httpResponse) {
}
@Override
public void failed(UnirestException e) {
}
@Override
public void cancelled() {
}
});
return future;
}
}
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE