POST request to config webhook in java

java
webhooks

#1

Hi all,

i have a problem when i try to config a new webhook for my api. Im using Java and i do it like this:

HttpClient httpclient = HttpClients.createDefault();
                  HttpPost httppost =
                      new HttpPost("https://api.twitter.com/1.1/account_activity/webhooks.json");

                  // Parameters
                  String rute = url + "/api/webhook";
                  List <NameValuePair> parameters = new ArrayList <NameValuePair>();
                  parameters.add(new BasicNameValuePair("url", rute));
                  httppost.setEntity(new UrlEncodedFormEntity(parameters, "UTF-8"));

                  // OAUTH
                  OAuthConsumer consumer = new CommonsHttpOAuthConsumer("XX",
                      "XX");
                  consumer.setTokenWithSecret("XX", "XX");
                  consumer.sign(httppost);

                  // Execute and get the response
                  HttpResponse response = httpclient.execute(httppost);

when i execute this i get a 400 bad response. Any ideas? if i try to execute a request in postman it works perfect if i put the url parameter in “x-www-form-urlencoded”, but in java i cant. I have other method that delete a webhook working, but it havent url parameter…

Thanks!!