My question is, I'm using postman to simulate these requests, so when I choose there to show the code as it would be in java it shows this code below, but it's full of "strange characters" like this WebKitFormBoundary7MA4YWxkTrZu0gW
and if I remove them the requisition does not work when I test here. Someone would know what these codes are about, and how would it be the correct way to send a post, with the data I want, a JSON for example, without having to add those codes, or at least some class or method that generates automatically when sending the request?
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW");
RequestBody body = RequestBody.create(mediaType, "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"grant_type\"\r\n\r\npassword\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"client_id\"\r\n\r\ntestclient\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"client_secret\"\r\n\r\ntestpass\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"username\"\r\n\r\nchaves\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"password\"\r\n\r\ndiscovoador\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--");
Request request = new Request.Builder()
.url("http://api.sualoja.com.br/oauth")
.post(body)
.addHeader("content-type", "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW")
.addHeader("cache-control", "no-cache")
.addHeader("postman-token", "ae657120-da97-0123-ed66-bea56efdd3a8")
.build();
Response response = client.newCall(request).execute();