0

When I build the request as below:

new Request.Builder()
            .url("https://bla.com/entry/1411641")
            .build();

The 1411641 becomes https://bla.com/entry/%EF%BB%BF1411641

Is there a way to build the request without encoding the URL?

arin
  • 1,774
  • 22
  • 35
  • 2
    Are you sure this character was not there in your original URL? OKHttp would not add such a thing. – Henry Dec 28 '17 at 07:27

4 Answers4

1

You have a Unicode Character 'ZERO WIDTH NO-BREAK SPACE' (U+FEFF) in your input, edit the text you copied and remove it.

http://www.fileformat.info/info/unicode/char/feff/index.htm

UTF-8 (hex) 0xEF 0xBB 0xBF (efbbbf)

Yuri Schimke
  • 12,435
  • 3
  • 35
  • 69
0

Use this :

new Request.Builder()
            .baseUrl("https://bla.com")
            .build();

and in interface

@GET("/entry/{id}/")
Call<ResponseBody> getData(@Path("id") String yourId);
Abubakker Moallim
  • 1,610
  • 10
  • 20
0

Use This:

final Request request = new Request.Builder()
.url(HttpUrl.parse("https://bla.com").newBuilder().addPathSegment("entry").addPathSegment("1411641").build())
                .post(formBody)
                .build();
OkHttpClient client = new OkHttpClient();
client.newCall(request).enqueue(new Callback() {
            @Override
            public void onFailure(@NonNull Call call, @NonNull IOException e) {

            }

            @Override
            public void onResponse(@NonNull Call call, @NonNull final Response response) throws IOException {
            }
        });
AMT
  • 136
  • 5
0

This additional symbols is encoded byte order mask (see https://en.wikipedia.org/wiki/Byte_order_mark). This hidden characters is conteined in file from which you copied (or programmatically read) id of entry.

Just skip this symbols when read your file. Or open this file with proper encoding.

Anton Tupy
  • 951
  • 5
  • 16
  • Maybe this is it: https://stackoverflow.com/questions/33510700/excel-files-with-byte-order-mark-for-utf-8-causing-errors I will give that a shot. Thanks! – arin Dec 28 '17 at 17:50
  • http://www.fileformat.info/info/unicode/char/feff/index.htm UTF-8 (hex) 0xEF 0xBB 0xBF (efbbbf) – Yuri Schimke Dec 29 '17 at 08:18