I am using okhttp client to make requests to twitter. When the request body(status param) contains % it getting failed.
below is the code I am using to make a request
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "status=test % test&media_ids=1690251004548407296");
Request request = new Request.Builder()
.url("https://api.twitter.com/1.1/statuses/update.json")
.method("POST", body)
.build();
Response response = client.newCall(request).execute();
When i remove the % from the status param it is getting successfull otherwise, I am getting 400 error.
But the same has been working with POSTMAN. I have copied the code from postman. Also I tried unirest client, it is working without issues in unirest.