Skip to content

Commit

Permalink
fixed post body in okhttp
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilal Al committed Sep 12, 2024
1 parent 3c853dc commit a50d79a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@

import okhttp3.*;
import okhttp3.logging.HttpLoggingInterceptor;
import okhttp3.MediaType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.Proxy;
import java.net.URI;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -130,12 +132,10 @@ public SplitHttpResponse post(URI url, String entity,
setAdditionalAndDecoratedHeaders(requestBuilder, additionalHeaders);
requestBuilder.addHeader("Accept-Encoding", "gzip");
requestBuilder.addHeader("Content-Type", "application/json");
// String post = EntityUtils.toString((HttpEntity) entity);
RequestBody postBody = RequestBody.create(entity.getBytes());
RequestBody postBody = RequestBody.create(MediaType.parse("application/json; charset=utf-16"), entity);
requestBuilder.post(postBody);

Request request = requestBuilder.build();
System.out.println(request);
_log.debug(String.format("Request Headers: %s", request.headers()));

Response response = httpClient.newCall(request).execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void testCreateClient() throws Exception {
.readTimeout(11000)
.build();

module.createClient(apiToken, sdkMetadata, requestDecorator);
module.createClient(apiToken, sdkMetadata); //, requestDecorator);
assertThat(true, is(equalTo(argsCaptured.get())));
}
}

0 comments on commit a50d79a

Please sign in to comment.