Here I need to pass Authorization Bearer to get response from server in case of uploading file to server I am using retrofit.
I tried in two ways
1)
This is how I initialized in retrofit interface class
@POST("document/kycDocument/user/3")
Call<UploadKycpojo> uploadkycdoc(@Header("Authorization")String token, @Body UploadKycRequest uploadKycRequest);
This is how I called it from interface class
Call<UploadKycpojo> request = RestClient.getInstance(UploadIdActivtiy.this).get().uploadkycdoc("Bearer "+auth,uploadKycRequest);
2)
OkHttpClient client = new OkHttpClient.Builder().addInterceptor(new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
Request newRequest = chain.request().newBuilder()
.addHeader("Authorization", "Bearer " + token)
.build();
return chain.proceed(newRequest);
}
}).build();
Retrofit retrofit = new Retrofit.Builder()
.client(client)
.baseUrl(/** your url **/)
.addConverterFactory(GsonConverterFactory.create())
.build();
Any help will be appreciated. Thanks in Advance!
/
before the URL in post – DuboseResponseBody
object instead ofUploadKycpojo
.. then parse the json by hand... – Dubose