title: Retrofit add custom headers as token - java
body: <p>I just learn the basic of retrofit android however i have so many question regarding headers.</p>
  
  <p>I have a REST API server and before my api export data it request to have API KEY which is stored on Header Authorization. now on my case before executing i want to initialized the API KEY into the header.</p>
  
  <p>here's my code</p>
  
  <pre><code>public interface VerifyClient{
  
      @Headers("Authorization: eNortjI0s1LKTSxKSUyvckguLcuv0EtJ") // &lt;======================
      @FormUrlEncoded
      @POST("/sendcode/{id}")
      VerifyResponse verify(@Path("id") String id, @Field("to") String to, @Field("type") String type, @Field("code") String code);
  
  }
  </code></pre>
  
  <p>This work fine but the problem is what if another client api key? </p>
  
  <p>another approach is this.</p>
  
  <pre><code>RequestInterceptor requestInterceptor = new RequestInterceptor()
              {
                  @Override
                  public void intercept(RequestFacade request) {
                      request.addHeader("Authorization", ApiKey); &lt;======================
                  }
              };
  
              return new RestAdapter
                      .Builder()
                      .setEndpoint(Var.REST_URL)
                      .setRequestInterceptor(requestInterceptor)
                      .build()
                      .create(VerifyClient.class)
                      .verify(userData[0], userData[1], userData[2], userData[3]);
          }
  </code></pre>
  
  <p>But it return <code>401 Unauthorized</code> hmmm anyone has a solution for this? or maybe i implemented it wrong. </p>