Skip to content

Commit

Permalink
Small tidyups
Browse files Browse the repository at this point in the history
  • Loading branch information
mcasperson committed Jan 30, 2022
1 parent 691c4e5 commit 5f5f486
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ public String translate(final String input, final String sourceLanguage,

final OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create("[{\"Text\": \""
final MediaType mediaType = MediaType.parse("application/json");
final RequestBody body = RequestBody.create("[{\"Text\": \""
+ StringEscapeUtils.escapeJson(input) + "\"}]", mediaType);
Request request = new Request.Builder().url(url).post(body)
final Request request = new Request.Builder().url(url).post(body)
.addHeader("Ocp-Apim-Subscription-Key", System.getenv("TRANSLATOR_KEY"))
.addHeader("Ocp-Apim-Subscription-Region", System.getenv("TRANSLATOR_REGION"))
.addHeader("Content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
final Response response = client.newCall(request).execute();
return response.body().string();
}
}

0 comments on commit 5f5f486

Please sign in to comment.