private String doPostRequest() throws IOException, ClientProtocolException {
    HttpPost request = new HttpPost(method.buildUrl());
    request.addHeader("Content-Type", "application/json");
    request.addHeader("Accept", "application/json");
    Gson gson = GsonProvider.getGson();
    String rawBody = gson.toJson(requestObject);
    Log.d("REMOTE_DO_POST", rawBody);
    request.setEntity(new StringEntity(rawBody));

    StringBuilder sb = new StringBuilder();

    Header[] headers = request.getAllHeaders();
    for (Header header : headers) {
      sb.append(header.getName() + ":: " + header.getValue() + "::");
    }

    return innerApiCall(request);
  }
Пример #2
0
 /**
  * Creates a new API client instance providing Auth0 account info.
  *
  * @param auth0 account information
  */
 public AuthenticationAPIClient(Auth0 auth0) {
   this(auth0, new OkHttpClient(), GsonProvider.buildGson());
 }
 /**
  * @param method
  * @param parameter
  * @param destinyClass
  * @return Something of type T
  * @throws ClientProtocolException
  * @throws IOException
  */
 private T doRequest() throws ClientProtocolException, IOException {
   String plainObject = innerDoRequest(method, requestObject);
   Log.d("REMOTE_RESPONSE", plainObject);
   Gson gson = GsonProvider.getGson();
   return gson.fromJson(plainObject, targetResponseClass);
 }