0

I'm using Okio to download a file....with my request i'm sending some parameters, but since I wasn't getting my file and I was able to log my request and this is what is see:

Why tags is null? that means that the parameters are null

Request: Request{method=POST, url=https://mywesite.com/, tag=null}

 RequestBody requestBody = new MultipartBody.Builder()
                    .setType(MultipartBody.FORM)
                    .addFormDataPart("user", "test")
                    .addFormDataPart("pass", "1234")
                    .build();
            Request request = new Request.Builder()
                    .url(imageLink)
                    .post(requestBody)
                    .build();
Arbaz Pirwani
  • 935
  • 7
  • 22
Pedro
  • 1,440
  • 2
  • 15
  • 36

1 Answers1

0

Here is example:

String post(String url, String json) throws IOException {
    RequestBody body = RequestBody.create(JSON, json);
    Request request = new Request.Builder()
        .url(url)
        .post(body)
        .build();
    try (Response response = client.newCall(request).execute()) {
      return response.body().string();
    }
  }

from: https://github.com/square/okhttp/blob/master/samples/guide/src/main/java/okhttp3/guide/PostExample.java

Marek Kondracki
  • 1,372
  • 2
  • 8
  • 13