title: Retrofit2 - Can't get basic authentication for webAPI with dynamic URL
body: <p>I'm familiar with how to use dynamic URLs with Retrofit2 but having issue sending username &amp; password in the request. The webAPI works by entering a URL, a login prompt appears on the screen for a username &amp; password, after authentication a JSON response is displayed. The interface is defined for a dynamic URL:</p>
  
  <pre><code>@GET
  public Call&lt;User&gt; getJSON(@Url String string);
  </code></pre>
  
  <p>My request is as follows:</p>
  
  <pre><code>Retrofit retrofit = new Retrofit.Builder()
              .baseUrl(API_URL)
              .addConverterFactory(GsonConverterFactory.create())
              .build();
  
      LoginService service = retrofit.create(LoginService.class);
  
      Call&lt;User&gt; call = service.getJSON("https://username:password@api.url.com/");
  
      call.enqueue(new Callback&lt;User&gt;() {
          @Override
          public void onResponse(Call&lt;User&gt; call, retrofit2.Response&lt;User&gt; response) {
              System.out.println("Response status code: " + response.code());
  </code></pre>
  
  <p>I'm certain the URL is correct as it works in the browser &amp; but I keep getting error the username &amp; password aren't correct?</p>
  
  <pre><code>I/System.out: Response status code: 401
  </code></pre>
  
  <p>Also, as far as I can tell I can only use @GET rather than @POST because whenever I try @POST the response code is:</p>
  
  <pre><code>I/System.out: Response status code: 405
  </code></pre>
  
  <p>At first I tried to follow something similar to <a href="https://stackoverflow.com/questions/32559333/retrofit-2-dynamic-url">this post</a> using an encoded flag because it's an example of how to use @PATH &amp; @URL with Retrofit2 but didn't have any success. That's why I tried the username:password@ prepend to the URL. Most of the other examples all use the @POST method.</p>
  
  <p>Any feedback or ideas on how I can authenticate? Thanks</p>