Skip to content
Advertisement

Tag: okhttp

FATAL EXCEPTION: OkHttp Dispatcher

I’m using the OkHttp library in my android app to make web requests to a weather API. I’ve already implemented my code and I’m getting a FATAL EXCEPTION when doing the request. I’ve already added INTERNET permissions in my manifest too. MainActivity.java: Gradle: Then, here’s the exception I’m getting: I don’t know what to do at this point. I’ve read

Request working fine in postman, but getting a 403 in OkHTTP

I’m trying to make a request to the Genius API, but I’m running into some issues using OkHTTP. This is my small script I’m using to make the call: When I run this script, I get a 403 error: For reference, here is a picture of me making the same exact request with Postman, and it works: Any ideas on

why use Retrofit when we have OkHttp

with OkHttp we can make HTTP request then get response from server then with Gson lib convert response to object we need. this is from Square/OkHttp doc: Its request/response API is designed with fluent builders and immutability. It supports both synchronous blocking calls and async calls with callbacks I read from stackOverFlow Retrofit uses OkHTTP automatically if available . So

Logging with Retrofit 2

I’m trying to get the exact JSON that is being sent in the request. Here is my code: But I only see this in the logs: How am I supposed to do proper logging, given the removal of setLog() and setLogLevel() which we used to use with Retrofit 1? Answer In Retrofit 2 you should use HttpLoggingInterceptor. Add dependency to

Can’t get OkHttp’s response.body.toString() to return a string

I’m trying to get some json data using OkHttp and can’t figure out why when i try logging the response.body().toString() what i get is Results:﹕ com.squareup.okhttp.Call$RealResponseBody@41c16aa8 I don’t know what i’m doing wrong here. How do i get the response string? Answer Just in case someone bumps into the same weird thing as I have. I run my code during

Advertisement