Answer the question
In order to leave comments, you need to log in
Where can there be an error in the put request?
In my application I am trying to refresh an access token using a refresh_token. Here in the documentation I have a successful server response with the correct request:
HTTP 200
{
"expires_in": UNIX_TIMESTAMP,
"access_token": str,
"refresh_token": str
}
@Headers("Content-type: application/json")
Call<GetToken> getNewToken (@Path("refresh_token") String refresh_token);
public void updateToken() {
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build();
tok_pref2 = Objects.requireNonNull(getActivity()).getSharedPreferences(REFRESH_TOKEN,Context.MODE_PRIVATE);
String token = tok_pref2.getString(REFRESH_TOKEN,"");
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://сервер/")
.client(client)
.addConverterFactory(GsonConverterFactory.create())
.build();
APIService mAPIService2 = retrofit.create(APIService.class);
mAPIService2.getNewToken(token).enqueue(new Callback<GetToken>() {
@Override
public void onResponse(@NonNull Call<GetToken> call,@NonNull Response<GetToken> response) {
}
@Override
public void onFailure(@NonNull Call<GetToken> call,@NonNull Throwable t) {
Toast.makeText(getContext(),"Failure!!!",LENGTH_LONG).show();
}
});
}
<-- 404 https://сервер/v1/токен (210ms)
Content-Length: 41
P3P: policyref="/w3c/p3p.xml", CP="NOI ADM DEV COM NAV OUR STP"
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: application/json
08-14 03:04:54.257 3345-3394/com.example.developer_4.test_login D/OkHttp: {"message": "not_found", "error_code": 5}
<-- END HTTP (41-byte body)
Answer the question
In order to leave comments, you need to log in
Are you sure that the token should be sent in the url? 404, it doesn't see that url. I suspect this is the case.
double.Parse(textBox1.Text); - what decimal separator is used?
If you use a dot, then you should write double.Parse(textBox1.Text, CultureInfo.InvariantCulture);
The point is the decimal separator:
string value = textBox1.Text;
// меняем разделитель на текущий
value = System.Text.RegularExpressions.Regex.Replace(value, @",|\.", System.Globalization.NumberFormatInfo.CurrentInfo.CurrencyDecimalSeparator);
// преобразуем строку в число
var result = double.Parse(value);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question