OkHttp Post does not receive data sent from the server side

I am trying to send token to the server using OKHTTP library but am not getting the post request sent from the application. I have already added the internet permission in my Manifest. private void registerToken(String token) { final OkHttpClient cli

Difference between okhttp and httpurlconnection?

What are the differences between these 2 libraries? How I understood there is a difference between these 2 lib also because Volley uses httpurlconnection and Retrofit the okhttp.... But I don't understand the difference between them and pros and cons

Retrofit add header with token and id

I have a problem with getting authenticated user. Before it I got token and user id. Now i need to get user from server using access token and id. I have header format Now I'am trying to add header with user token and id using interceptor. My code: I

Send JSON body via POST request in OKhttp in Android

I have setting up OkHttpClient and successfully sending the GET request to the server. And also I could able to sending the POST request to the server with empty body tag. Now, I'm trying to send the following JSON Object to the server. { "title"

Iterate on the parameters for the query

I have a Map<String,String> params = ..... with the key+value for the parameters for a GET request. Building a HttpUrl looks something like this: HttpUrl httpUrl = new HttpUrl.Builder() .scheme("https") .host("example.com") .addE

OKhttp multi-part logging interceptor

I am trying to upload an image using okHTTP multi part into a server. the server does not accept my request. my problem is that I cannot see the parts of my multi part in the logging intercepter, so I cannot debug. here is the code that I use and the

Download pdf file using OKHTTP

I am using ok-http in my android application. I have url of .pdf file which is coming from web-service. I have to download pdf file on click event of ImageView. I have searched it on google but, couldn't find specific answer. Please, provide me solut

Resolution failed: okhttp logging-interceptor

I am using Retrofit 2.0.0-beta2 library for the communication with the API. Until last friday, everything worked fine. Today I get this error: Failed to resolve: com.squareup.okhttp:logging-interceptor:2.6.0-SNAPSHOT and I cannot get rid of it. I've

okhttp alternative container

Ok I ma having problem with understanding okhttp. all I need is to upload an image to server. this image is screenshot from my android studio , it seems I cannot import org.apache.http.NameValuePair; what is alternative container then ? and as you no

OkHttp RequestBody returning an incorrect length of content

I have this app where I use OkHttp RequestBody to perform network requests with body, but the content length being returned is plain wrong. As an example of the problem, there is this case: public static RequestBody createNewTokenBody(final String re

Okhttp multithreading authenticator

I am using okhttp library in my android application with several async requests. All requests requires token to be set in header. Sometimes I need to refresh that token using provided RefreshToken, so I decide to use OkHttp's Authenticator class. Wha

Certificate Pinning Does Not Work with OkHttp on Android

Using com.squareup.okhttp:okhttp:2.4.0 with com.squareup.retrofit:retrofit:1.9.0 on an Android app, trying to communicate with an server REST API over HTTPS, that uses a self signed certificate. Server keystore has a private key and 2 certificates, t

Retrofit + Okhttp cancel the operation does not work

I am using retrofit in my application like this final OkHttpClient okHttpClient = new OkHttpClient(); okHttpClient.interceptors().add(new YourInterceptor()); final OkClient okClient = new OkClient(okHttpClient); Builder restAdapterBuilder = new RestA

Memory card leaks memory

I have a simple ListActivity that shows images and I inizialize my OkHttpClient for Picasso Builder in the constructor of the ImageAdapter class: picassoClient = new OkHttpClient(); picassoClient.interceptors().add(new Interceptor() { @Override publi

Authentication Management in Okhttp

I'm using OkHttp 2.3 with basic authentication requests, according to OKHttp docs, it automatically retries unauthenticated requests, but whenever I provide invalid credentials, the request takes too much time and I get this exception in the end: jav

OkHttp Library - NetworkOnMainThreadException on Simple Post

I want to use OkHttp library for networking in Android. I started with the simple post example as written in their website: public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); OkHttpClient client = new OkHttp

Caching data with OKHttp

I'm trying to cache data with OKHttp's native cache; my problem is that I don't have control over the server side data, and the response header Cache-Control is coming back with a "no-cache" value. Is there anyway to intercept the request to add

How to specify a default user agent for okhttp 2.x queries

I am using okhttp 2.0 in my Android app and didn't find a way to set some common User Agent for all outgoing requests. I thought I could do something like OkHttpClient client = new OkHttpClient(); client.setDefaultUserAgent(...) ...but there's no suc

How can I pin a certificate with Square OKHTTP?

I think I need to create a new SSL Socket Factory? Also, I don't want to use the global SSL Context (https://github.com/square/okhttp/issues/184) for obvious reasons. thanks! EDIT: As of okhttp 2.1.0 you can pin certificates very easily. See the sour

How to disable SSLv3 fallback with okhttp

My android application relies on SNI to access the correct server, so it requires TLS and won't work with SSLv3. I'm using okhttp and retrofit and server logs indicate that suddenly TLS handshakes switch to SSLv3 and may stay this way for a log time,