Retrofit 2 - delayed response - android

I have a problem with retrofit 2. I'm sending some data to Microsoft EAS server but a response is received after 20 sec. Why I know that this is a retrofit problem? Because without retrofit it is working correctly.
my logs:
D/OkHttp: --> POST https://{my_host}/Microsoft-Server-ActiveSync?Cmd=Provision&User={myuser}&DeviceId=837bc6c5690b40b98ab55f7a2231e50c&DeviceType={mydevicetype} http/1.1
D/OkHttp: Content-Type: application/vnd.ms-sync.wbxml
D/OkHttp: Content-Length: 456
D/OkHttp: Authorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
D/OkHttp: MS-ASProtocolVersion: 14.1
D/OkHttp: Connection: keep-alive
D/OkHttp: User-Agent: MyUserAgent
D/OkHttp: X-MS-PolicyKey: 0
D/OkHttp: [3,1,106,0,0,14,[...more here...],88,77,76,0,1,1,1,1] // <--- body
D/OkHttp: --> END POST (456-byte body)
after 20 sec (it seems like I receive response after 20 + normal receive time - in this case: 20596ms):
D/OkHttp: <-- 200 OK https://{my_host}/Microsoft-Server-ActiveSync?Cmd=Provision&User={myuser}&DeviceId=837bc6c5690b40b98ab55f7a2231e50c&DeviceType={mydevicetype} (20596ms)
D/OkHttp: Content-Type: application/vnd.ms-sync.wbxml
D/OkHttp: request-id: {request_id}
D/OkHttp: Set-Cookie: {cookie_data}
D/OkHttp: X-CalculatedBETarget: {target}.local
D/OkHttp: X-MS-BackOffDuration: L/-470
D/OkHttp: X-DiagInfo: EXCHANGEHA
D/OkHttp: X-BEServer: EXCHANGEHA
D/OkHttp: Set-Cookie: {cookie_data}
D/OkHttp: X-FEServer: EX01
D/OkHttp: Date: Fri, 07 Oct 2016 10:30:08 GMT
D/OkHttp: <-- END HTTP (binary 15-byte body omitted)
If I'm requesting it without retrofit, it sends me response immiedetaly.
My code:
Init:
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
httpClient.addInterceptor(chain -> {
Request original = chain.request();
Request.Builder requestBuilder = original.newBuilder()
.addHeader("Authorization", getAuth(account))
.addHeader("MS-ASProtocolVersion", getProtocolVersion())
.addHeader("Connection", getConnectionType())
.addHeader("User-Agent", getUserAgent())
.addHeader("X-MS-PolicyKey", getPolicyKey());
Request request = requestBuilder.build();
return chain.proceed(request);
});
if (EasConfig.isDebug()) {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
httpClient.addInterceptor(logging);
}
httpClient.readTimeout(30, TimeUnit.SECONDS);
httpClient.writeTimeout(30, TimeUnit.SECONDS);
OkHttpClient client = httpClient.build();
retrofit = new Retrofit.Builder()
.baseUrl(getBaseUrl(account))
.addConverterFactory(GsonConverterFactory.create())
.client(client)
.build();
Call:
ActiveSyncService service = retrofit.create(ActiveSyncService.class);
service.getData(getContentType(), command, getUser(account), getDeviceId(), getUserAgent(), serializer.toByteArray());
Endpoint:
#POST("Microsoft-Server-ActiveSync")
Call<ResponseBody> getData(#Header("Content-Type") String contentType, // <--- it has to be here -- it's not woking if I set it in incerteptor (don't know why)
#Query("Cmd") String command,
#Query("User") String user,
#Query("DeviceId") String deviceId,
#Query("DeviceType") String deviceType,
#Body byte[] data);

Related

Adding OkHttpClient interceptor makes the request proceed multiple times

I was trying to add refresh token interceptor to http client
public class AuthInterceptor implements Interceptor {
private Disposable disposable;
#Override
public Response intercept(#NonNull Chain chain) throws IOException {
Request request = chain.request();
Response response = chain.proceed(request);
// if (response.code() == HttpURLConnection.HTTP_UNAUTHORIZED) {
//
// synchronized (chain) {
//
//
// RefreshTokenApi refreshTokenApi = new RefreshTokenApi();
// disposable = refreshTokenApi.call().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(
// (tokenResponse, throwable) -> {
//
// PreferencesWrapperImpl.SINGLETON.putStringForKey(tokenResponse.getResponse().header(Constants.AUTH_TOKEN), Constants.PreferenceKey.AUTH_TOKEN_KEY);
// Log.e("throwable", throwable.getMessage());
//
// });
//
//
// Request newRequest = request.newBuilder()
// .removeHeader(Constants.AUTH_TOKEN)
// .addHeader(Constants.AUTH_TOKEN, PreferencesWrapperImpl.SINGLETON.getStringForKey(Constants.PreferenceKey.AUTH_TOKEN_KEY, null))
// .build();
// response = chain.proceed(newRequest);
// }
// }
return response;
}
}
then i discovered that the request proceed many times so i thought that maybe my synchronized logic wrong and that is what caused request to occur multiple time so i commented the synchronized logic but actually the request still occur many times
and here is my logcat
D/OkHttp: --> POST http://134.209.26.2:88/api/common/version/check http/1.1
D/OkHttp:
--> POST http://134.209.26.2:88/api/common/version/check http/1.1
Content-Type: application/json; charset=utf-8
Content-Length: 35
D/OkHttp: Content-Type: application/json; charset=utf-8
Content-Length: 35
D/OkHttp: Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC8xMzQuMjA5LjI2LjI6ODhcL2FwaVwvc3BcL2F1dGhcL2xvZ2luIiwiaWF0IjoxNTg3NjQxMjY5LCJleHAiOjE1ODc2NzcyNjksIm5iZiI6MTU4NzY0MTI2OSwianRpIjoiZThXQUpIenVSamdGOGpORyIsInN1YiI6MTMsInBydiI6Ijg3ZTBhZjFlZjlmZDE1ODEyZmRlYzk3MTUzYTE0ZTBiMDQ3NTQ2YWEiLCJwaWQiOjUsInR5cGUiOjF9.sA3-Ga9YI-4AyDZV_KIuOukONu3Abblq6ge8JbaMgp8
x-lang-code: en-us
D/OkHttp: Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC8xMzQuMjA5LjI2LjI6ODhcL2FwaVwvc3BcL2F1dGhcL2xvZ2luIiwiaWF0IjoxNTg3NjQxMjY5LCJleHAiOjE1ODc2NzcyNjksIm5iZiI6MTU4NzY0MTI2OSwianRpIjoiZThXQUpIenVSamdGOGpORyIsInN1YiI6MTMsInBydiI6Ijg3ZTBhZjFlZjlmZDE1ODEyZmRlYzk3MTUzYTE0ZTBiMDQ3NTQ2YWEiLCJwaWQiOjUsInR5cGUiOjF9.sA3-Ga9YI-4AyDZV_KIuOukONu3Abblq6ge8JbaMgp8
D/OkHttp: x-user-type: 1
D/OkHttp: x-lang-code: en-us
x-user-type: 1
D/OkHttp: {"user_platform":1,"version":"1.0"}
--> END POST (35-byte body)
D/OkHttp: {"user_platform":1,"version":"1.0"}
--> END POST (35-byte body)
D/OkHttp: <-- 200 OK http://134.209.26.2:88/api/common/version/check (446ms)
D/OkHttp: Date: Sat, 25 Apr 2020 22:01:29 GMT
Server: Apache/2.4.29 (Unix) OpenSSL/1.0.2n PHP/7.2.1 mod_perl/2.0.8-dev Perl/v5.16.3
D/OkHttp: <-- 200 OK http://134.209.26.2:88/api/common/version/check (447ms)
D/OkHttp: Vary: Authorization
D/OkHttp: Date: Sat, 25 Apr 2020 22:01:29 GMT
D/OkHttp: X-Powered-By: PHP/7.2.1
D/OkHttp: Server: Apache/2.4.29 (Unix) OpenSSL/1.0.2n PHP/7.2.1 mod_perl/2.0.8-dev Perl/v5.16.3
D/OkHttp: Cache-Control: no-cache, private
D/OkHttp: Vary: Authorization
D/OkHttp: Content-Length: 46
D/OkHttp: X-Powered-By: PHP/7.2.1
D/OkHttp: Keep-Alive: timeout=5, max=100
D/OkHttp: Cache-Control: no-cache, private
D/OkHttp: Connection: Keep-Alive
D/OkHttp: Content-Length: 46
D/OkHttp: Content-Type: application/json
D/OkHttp: Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: application/json
{"data":{"status":1,"min":null,"latest":null}}
D/OkHttp: {"data":{"status":1,"min":null,"latest":null}}
<-- END HTTP (46-byte body)
D/OkHttp: <-- END HTTP (46-byte body)
E/APP_UPDATES: onSuccess
i use logging interceptor to so as you see the first request of app which is app updates post many times

Android: get cookie from header in retrofit

I am creating new sample app with dagger, Rx, MVP and retrofit2. I am new in retrofit .For loginActivity i have send parameters as json string to web service.If the user exist and has permission, service return true in body and in header send Cookie:
D/Payesh: --> POST http://test.com/Authentication.svc/json/Login
D/Payesh: Content-Type: application/json; charset=utf-8
D/Payesh: Content-Length: 183
D/Payesh: {"username":"****","password":"***","customCredential":"****","isPersistent":false}
D/Payesh: --> END POST (183-byte body)
/data/data/com.groot.payesh/cache/okhttp_cache/journal.tmp
D/Payesh: <-- 200 OK http://test.com/Authentication.svc/json/Login (2111ms)
D/Payesh: Cache-Control: private
D/Payesh: Content-Type: application/json; charset=utf-8
D/Payesh: Server: Microsoft-IIS/8.5
D/Payesh: Set-Cookie: ASP.NET_SessionId=3pi1nyrozbjwagw543Wsck4; path=/
D/Payesh: Set-Cookie: .ASPXAUTH=EA9127C4A3002F1D5EA5AADC279....; expires=Tue, 27-Mar-2018 15:17:22 GMT; path=/
D/Payesh: X-Frame-Options: SAMEORIGION
D/Payesh: Access-Control-Allow-Origin: test.com
D/Payesh: Access-Control-Allow-Headers: Content-Type, Accept
D/Payesh: Access-Control-Allow-Methods: GET, POST
D/Payesh: Access-Control-Max-Age: 1728000
D/Payesh: Access-Control-Allow-Credentials: true
D/Payesh: Date: Mon, 26 Mar 2018 15:17:22 GMT
D/Payesh: Content-Length: 4
D/Payesh: true
D/Payesh: <-- END HTTP (4-byte body)
this is my ApiService:
#POST(UrlManager.AUTHENTICATION+"Login")
Observable<String> getAuthentication(#Body RequestBody params);
this method return a string and i received True when i run my app an get user and pass.
this is my observer method:
public DisposableObserver<String> observer() {
return new DisposableObserver<String>() {
#Override
public void onNext(String responseBody) {
Log.i("--->", "onNext: " + responseBody);
}...
I need this line in header:
Set-Cookie: .ASPXAUTH=EA9127C4A3002F1D5EA5AADC279....; expires=Tue, 27-Mar-2018 15:17:22 GMT; path=/
this is my Interceptor that initialized with dagger from My Application Class:
#AppScope
#Provides
public HttpLoggingInterceptor httpLoggingInterceptor() {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
#Override
public void log(String message) {
Timber.d(message);
}
});
return logging.setLevel(HttpLoggingInterceptor.Level.BODY);
}
How can i get Set-Cookie value?

Retrofit 2 - POST request became GET?

My POST request keeps sending as GET & got rejected by API endpoint
MyService class
#FormUrlEncoded
#POST("api/users/")
Call<List<User>> getUsers(#FieldMap HashMap<String, String> parameters);
Request code
Gson builder = new GsonBuilder().setLenient().create();
Retrofit client = new Retrofit.Builder()
.baseUrl(Constants.API_ENDPOINT_TEST_URL)
.addConverterFactory(GsonConverterFactory.create(builder))
.build();
mApiService = client.create(MyService.class);
Call<List<User>> call = mApiService.getUsers(mParameters);
call.enqueue(new Callback<List<User>>() {
#Override
public void onResponse(Call<List<User>> call, Response<List<User>> response) {
mResponse = response.body();
mResponseObserver.onFinish(mResponse);
}
#Override
public void onFailure(Call<List<User>> call, Throwable t) {
mResponseObserver.onFailure();
}
});
But server rejects it as it reached the server in GET request form !? Having checked with debugger, I saw that:
rawResponse.request.method = GET
Here is screenshot of watch window showing the retrofit's request object:
As you can see, the request method was GET. But the weird part is in the tag, it shows a request object with POST method?
Am i miss something here?
UPDATE
I added logging interceptor & here is the log:
D/OkHttp: --> POST http://***/api/users/ http/1.1
D/OkHttp: Content-Type: application/x-www-form-urlencoded
D/OkHttp: Content-Length: 56
D/OkHttp: --> END POST
D/OkHttp: <-- 200 OK https://***/api/users/ (388ms)
D/OkHttp: Date: Thu, 01 Sep 2016 11:50:23 GMT
D/OkHttp: Server: Apache
D/OkHttp: X-Powered-By: PHP/5.4.34
D/OkHttp: Cache-Control: max-age=2592000
D/OkHttp: Expires: Sat, 01 Oct 2016 11:50:23 GMT
D/OkHttp: Vary: Accept-Encoding
D/OkHttp: Content-Type: application/json; charset=UTF-8
D/OkHttp: Set-Cookie: SESSION_DEFAULT=***; expires=Sun, 04-Sep-2016 11:50:24 GMT; path=/; HttpOnly
D/OkHttp: Set-Cookie: COOKIE[***]=***; path=/; httponly
D/OkHttp: Connection: close
D/OkHttp: <-- END HTTP
looks like the request is a POST. But, the server still responds with error message, saying that the request method is a GET
Hmm, I'll dig a little bit more into it.
Actually, the issue is the combination of 2 factors:
Wrong request protocol has been made (http instead of https)
Server responded with a weird message on wrong protocol: "GET is not supported".
ANyway, thanks #nshmura for your assistant.
I checked your program with logging, and confirms the POST request is sent.
I recommend you to check like this:
class TestClass {
private void testRequest() {
HashMap<String, String> mParameters = new HashMap<>();
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.HEADERS);
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
httpClient.addInterceptor(logging); // <-- this is the important line!
Gson builder = new GsonBuilder().setLenient().create();
Retrofit client = new Retrofit.Builder()
.baseUrl(Constants.API_ENDPOINT_TEST_URL)
.addConverterFactory(GsonConverterFactory.create(builder))
.client(httpClient.build())
.build();
MyService mApiService = client.create(MyService.class);
Call<List<User>> call = mApiService.getUsers(mParameters);
call.enqueue(new Callback<List<User>>() {
#Override
public void onResponse(Call<List<User>> call, Response<List<User>> response) {
}
#Override
public void onFailure(Call<List<User>> call, Throwable t) {
}
});
}
interface MyService {
#FormUrlEncoded
#POST("api/users/")
Call<List<User>> getUsers(#FieldMap HashMap<String, String> parameters);
}
class User {
}
class Constants {
public static final String API_ENDPOINT_TEST_URL = "http://.........";
}
}
here is request log:
D/OkHttp: --> POST http://......... http/1.1
D/OkHttp: Content-Type: application/x-www-form-urlencoded
D/OkHttp: Content-Length: 0
D/OkHttp: --> END POST
Here is response:
D/OkHttp: <-- 200 OK http://.............../ (167ms)
D/OkHttp: Server: nginx
D/OkHttp: Date: Thu, 01 Sep 2016 11:30:32 GMT
D/OkHttp: Content-Type: text/html; charset=UTF-8
D/OkHttp: Connection: close
....
D/OkHttp: <-- END HTTP
I met a similar problem. In my case, I received in response to 301, redirect and change of method POST -> GET.
First, check your BASE_URL, it must be of the form "h ttps://www.YourSite.com/" www - very important. If everything is in place and the problem still exists, then you can change as described below:
From okhttp wiki and based on this image, you need to change something like this:
...
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
final RequestBody requestBody = new FormBody.Builder().build();
httpClient.addNetworkInterceptor(new Interceptor() {
#Override public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
HttpUrl.Builder builder = request.url().newBuilder();
HttpUrl url = builder.build();
request = request.newBuilder()
.url(url)
.post(requestBody)
.build();
return chain.proceed(request);
}
})
httpClient.addInterceptor(logging);
...
Can u try
#POST("/api/users/")
With slash before "api"?
Also it would be helpful to double check request with Fiddler or smth.
That is partly correct a http client behavior. According to the HTTP spec
If the 307 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued.
Sometime it is not possible to change backend API. So here a workaround you can add to you interceptor to manually redirect a request with correct method.
fun forceRedirectMethod(chain: Interceptor.Chain, originResponse: Response): Response {
/* TODO
one more request is made; disable followRedirect and make it manually?
*/
if (originResponse.priorResponse()?.code() == 302) {
val priorResponse: Response = originResponse.priorResponse() as Response
val redirectRequest = priorResponse.request()
val builder = originResponse.request().newBuilder()
.method(redirectRequest.method(), redirectRequest.body())
val newRequest = builder.build()
return chain.proceed(newRequest)
} else {
return originResponse
}
}

Android - Sending .wav file using RETROFIT2 for Speaker Recognition

I'm trying to send a .wav file using Retrofit2 on Android in order to use the Create Enrollment request of the Microsoft Speaker Recognition API (https://dev.projectoxford.ai/docs/services/563309b6778daf02acc0a508/operations/56406930e597ed20c8d8549c)
But I always get the following Error 400:
com.mobile.cir.voicerecognition D/OkHttp: <-- 400 Bad Request https://api.projectoxford.ai/spid/v1.0/verificationProfiles/94BC205B-FACD-42A7-9D80-485403106627/enroll (3907ms)
com.mobile.cir.voicerecognition D/OkHttp: Cache-Control: no-cache
com.mobile.cir.voicerecognition D/OkHttp: Pragma: no-cache
com.mobile.cir.voicerecognition D/OkHttp: Content-Length: 123
com.mobile.cir.voicerecognition D/OkHttp: Content-Type: application/json; charset=utf-8
com.mobile.cir.voicerecognition D/OkHttp: Expires: -1
com.mobile.cir.voicerecognition D/OkHttp: X-AspNet-Version: 4.0.30319
com.mobile.cir.voicerecognition D/OkHttp: X-Powered-By: ASP.NET
com.mobile.cir.voicerecognition D/OkHttp: apim-request-id: e5472946-ec90-4662-a3c9-dda62c2c6b27
com.mobile.cir.voicerecognition D/OkHttp: Date: Fri, 12 Aug 2016 11:43:04 GMT
com.mobile.cir.voicerecognition D/OkHttp: }
com.mobile.cir.voicerecognition D/OkHttp: <-- END HTTP (123-byte body)
com.mobile.cir.voicerecognition D/EnableVoiceRecognition: Upload success
com.mobile.cir.voicerecognition D/errorĀ message: RequestError{code='null', message='null'}
Here is my Apiclient class:
public static Retrofit getClient() {
if (retrofit==null) {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient httpClient = new OkHttpClient.Builder().addInterceptor(logging).build();
retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.client(httpClient)
.build();
}
return retrofit;
}
The POST request:
#Multipart
#POST("verificationProfiles/{VerificationProfileId}/enroll")
Call<EnrollmentResponse> createEnrollment(#Path("VerificationProfileId") String profileId,
#Header("Content-Type") String contentType,
#Header("Ocp-Apim-Subscription-Key") String subscriptionKey,
#Part("file") RequestBody audioFile);
}
And the action itself:
File audioFile = new File(fileDirectory + "my_voice.wav");
RequestBody requestAudioFile = RequestBody.create(MediaType.parse("application/octet-stream"), audioFile);
Call<EnrollmentResponse> call = apiService.createEnrollment(PROFILE_ID_TEST,"audio/wav; samplerate=1600",API_KEY,requestAudioFile);
call.enqueue(new Callback<EnrollmentResponse>() {
#Override
public void onResponse(Call<EnrollmentResponse> call, Response<EnrollmentResponse> response) {
Log.d(TAG,"Upload success");
RequestError error = ErrorUtils.parseError(response);
Log.d("error message", error.toString());
Log.d(TAG,"Response: " + response.body().toString());
}
#Override
public void onFailure(Call<EnrollmentResponse> call, Throwable t) {
Log.d(TAG,"Upload error: " + t.getMessage());
}
});
Where am I doing wrong?
* EDIT *
Microsoft developers released the Android library for this API
(https://github.com/Microsoft/Cognitive-SpeakerRecognition-Android)

API key is always missing when I try to access MailChimp's api using Retrofit

I'm sure this is a non issue for someone who knows what they're doing, but this is my first time using MailChimp's api and retrofit. Basically, my api key is always missing. I have no idea what MailChimp's proper url looks like when you are including an api key.
The url I am attempting is:
/3.0/lists/613cd953b2/members?user=email#gmail.com:apikey
And others of that variety
http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#create-post_lists_list_id_members
curl --request GET \
--url 'https://.api.mailchimp.com/3.0/' \
--user 'anystring:your_apikey'
This says GET but I am attempting a post.
Here is my android / java code...
final OkHttpClient client = new OkHttpClient();
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
client.interceptors().add(interceptor);
client.interceptors().add(new Interceptor() {
#Override
public com.squareup.okhttp.Response intercept(Chain chain) throws IOException {
Request original = chain.request();
Request.Builder requestBuilder = original.newBuilder()
// .header("Authorization", basic)
.header("user", "email#gmail.com:apikey");
Request request = requestBuilder.build();
return chain.proceed(request);
}
});
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.client(client)
.addConverterFactory(GsonConverterFactory.create())
.build();
//Create interface instance
MailChimpAPI apiService = retrofit.create(MailChimpAPI.class);
Email chimpEmail = new Email("hi#hi.hi");
Call<Email> call = apiService.addUser(chimpEmail);
call.enqueue(new Callback<Email>() {
#Override
public void onResponse(Response<Email> response, Retrofit retrofit) {
int statusCode = response.code();
//Log.d("tag", "enter the void");
Log.d("tag", statusCode + "");
Log.d("tag", client.toString());
}
#Override
public void onFailure(Throwable t) {
Log.d("tag", t.toString());
}
});
And how I define my interface method
#POST("/3.0/lists/613cd953b2/members")
Call<Email> addUser(#Body Email email);
And my retrofit log...
D/OkHttp: --> POST /3.0/lists/613cd953b2/members HTTP/1.1
D/OkHttp: {"email_address":"hi#hi.hi","merge_fields":{"FNAME":"","LNAME":""},"status":""}
D/OkHttp: --> END POST (79-byte body)
D/OkHttp: <-- HTTP/1.1 401 (299ms)
D/OkHttp: OkHttp-Selected-Protocol: h2
D/OkHttp: server: nginx
D/OkHttp: content-type: application/problem+json; charset=utf-8
D/OkHttp: x-request-id: 6b6ca6a9-c141-45fc-8de7-ec0922892bbf
D/OkHttp: link: <https://us12.api.mailchimp.com/schema/3.0/ProblemDetailDocument.json>; rel="describedBy"
D/OkHttp: vary: Accept-Encoding
D/OkHttp: date: Tue, 05 Jan 2016 21:21:45 GMT
D/OkHttp: set-cookie: _AVESTA_ENVIRONMENT=prod; path=/
D/OkHttp: OkHttp-Sent-Millis: 1452028904738
D/OkHttp: OkHttp-Received-Millis: 1452028904830
D/OkHttp: {"type":"http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/","title":"API Key Missing","status":401,"detail":"Your request did not include an API key.","instance":""}
D/OkHttp: <-- END HTTP (193-byte body)
I was not using basic authentication properly. I followed this tutorial
https://futurestud.io/blog/android-basic-authentication-with-retrofit
and it fixed my error! Yay for new errors!
Also for future people, maybe this might help you.
BASIC AUTHORIZATION isn't just a way to describe something! It's an actual concept and implementable! haha

Categories

Resources