Skip to content

Tag: retrofit

Retrofit: How to wait for response

I have AsyncTask and the doInBackground method inside which, I sending POST request using Retrofit. My code looks like: The problem is: Retrofit sending request asynchronously and while it, the doInBackground method returning the value. So I need to send a request in the same thread with all executions in the…

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. …

How to send byte[] array in retrofit

How do you send byte[] array in retrofit call. I just need to send over byte[]. I get this exception when I have been trying to send a retrofit call. retrofit.RetrofitError: retrofit.converter.ConversionException: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException:  Expected a string but was…

HTTP GET with request body RETROFIT

I am using Retrofit to make api calls in my android application. I have to submit a @Body of JSON I get error message Have you any idea? Answer To send data along with your Get Request you can do the following: as said in this SO answer, Server semantics for GET, however, are restricted such that a body, if

Declaring a retrofit REST endpoint with constant query value

So I want to get the metadata of a youtube video (say this one: https://www.youtube.com/watch?v=qlTA3rnpgzU). I’m going to encode it and wrap it in another url like so: http://www.youtube.com/oembed?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DqlTA3rnpgzU&format=json My interface definition will …